[Haskell-cafe] CPP and INLINE pragmas

Adam Langley agl at imperialviolet.org
Sun Jan 20 14:17:29 EST 2008


Since CPP mode removes newlines in the out macro expansion. It appears
to be impossible to have a macro expand to a function with an INLINE
pragma since it appears to need to be in its own line.

For example:

#define GETHOSTWORD(name, m, type) \
{-# INLINE name #-} \
name :: m type ; \
name = getPtr (sizeOf (undefined :: type)) \

Does work (since you can't follow the INLINE pragma with anything else
on the same line.

Likewise:

#define GETHOSTWORD(name, m, type) \
name :: m type ; \
name = getPtr (sizeOf (undefined :: type)) \
{-# INLINE name #-}

Also doesn't work since the INLINE needs to start at the beginning of a line.

Has anyone a workaround for this, or a way to get the preprocessor to
output a newline?


Cheers

AGL

-- 
Adam Langley                                      agl at imperialviolet.org
http://www.imperialviolet.org                       650-283-9641


More information about the Haskell-Cafe mailing list