On 02/28/2012 01:45 AM, Paul Eggert wrote: > On 02/27/2012 06:29 PM, Bruno Haible wrote: >> The current set of definitions >> >> #define _Noreturn __declspec (noreturn) >> #define noreturn _Noreturn >> >> leads to a syntax error when someone writes __declspec (noreturn), >> because preprocessing transforms it to __declspec (__declspec (noreturn)). >> >> How can this syntax error be avoided? > > I don't see any reasonable way to do it. > Perhaps we should just document that <stdnoreturn.h> is > incompatible with MSVC, unless it is included after all > system include files (yuck!).
This works: $ cat foo.c #define noreturn __declspec(noreturn) #define _Noreturn noreturn noreturn _Noreturn $ gcc -E foo.c | tail -n2 __declspec(noreturn) __declspec(noreturn) The trick is that on MSVC, we have to define noreturn in terms of itself, so that pre-processing doesn't recursively expand things, then _Noreturn is defined in terms of noreturn. I think that if <config.h> expands _Noreturn to 'declspec(noreturn)', but <stdnoreturn.h> undefined _Noreturn, defines noreturn, then redefines _Noreturn, that you'll have a working solution - so you need to add compiler conditionals to our <stdnoreturn.h> header to get this ordering for MSVC. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature