Re: _Pragma takes a parenthesized string literal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Ian,

After a few hours, I managed to come up with the following. It seems
the problem was with Apple and their [&*%@!#&^]
compiler/linker/version/who knows what else. Linux took behaved as
expected, as did Windows.

#if defined(__APPLE__) && defined(__MACH__)

# define COMPILE_MESSAGE(x) _Pragma (#x)

# define PRAGMA_MESSAGE(x) COMPILE_MESSAGE(warn (" " #x))
# define PRAGMA_WARNING(x) COMPILE_WARNING(warn (" " #x))

#elif defined(__linux__) || defined(__linux) || defined(linux)

# define COMPILE_MESSAGE(x) _Pragma (#x)

# define PRAGMA_MESSAGE(x) COMPILE_MESSAGE(message (" " #x))
# define PRAGMA_WARNING(x) COMPILE_WARNING(warn (" " #x))

#else

# define PRAGMA_MESSAGE(x) __pragma(message(#x))
# define PRAGMA_WARNING(x) __pragma(warning(#x))

#endif

Jeff

On Sat, Oct 16, 2010 at 11:01 PM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
> Jeffrey Walton <noloader@xxxxxxxxx> writes:
>
>> I need to move the following into a define.
>>
>> // Windows, Linux, Apple
>> #pragma message "Something interesting from cpp"
>
> This the closest I can get.  You have to write "message" explicitly in
> the usage.  I don't know how to avoid that, because string concatenation
> is not done before _Pragma arguments are evaluated.
>
> #define PRAGMA_MESSAGE(x) _Pragma(#x)
> PRAGMA_MESSAGE(message "Something interesting from cpp")
>
> Ian
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux