On 04/26/2012 02:54 AM, Vincent Lefevre wrote: > The gnulib code, as I can see it under Debian, looks strange. > In lib/stdnoreturn.in.h: > > #if 1200 <= _MSC_VER > /* Standard include files on this platform contain declarations like > "__declspec (noreturn) void abort (void);". "#define noreturn > _Noreturn" would cause this declaration to be rewritten to the > invalid "__declspec (__declspec (noreturn)) void abort (void);". > Instead, define noreturn to empty, so that such declarations are > rewritten to "__declspec () void abort (void);", which is > equivalent to "void abort (void);"; this gives up on noreturn's > advice to the compiler but at least it is valid code. */ > # define noreturn /*empty*/ > #else > # define noreturn _Noreturn > #endif > > IMHO, the problem with _MSC_VER (which is not a bug, because > "noreturn" wasn't reserved) means that using the <stdnoreturn.h> > header is not the right solution for code that needs to be pre-C11 > compatible; If I write C11 code: #include <stdnoreturn.h> #include <stdio.h> then I expect things to work. But _MSC_VER system headers use noreturn in a non-C11 manner, such that the only way for this to work via gnulib is to make 'noreturn' a no-op on that platform, until such time as Microsoft updates their headers. Microsoft has a history of namespace pollution; had their compiler used '__declspec (__noreturn)' instead of '__declspec (noreturn)', we would not be facing this clash. The whole point of gnulib is to give me enough support so that I can write code that is valid C11, and also which compiles under non-C11 compilers, without any extra #ifdef work in my code (since gnulib took care of it for me). > indeed some implementations may have another use of > "noreturn". Not if they were compliant to C99 (since C99 didn't reserve 'noreturn', then system headers under C99 mode should not be using that symbol). > > but I don't see how it can be correct on a non-GCC non-SunPro C11 > implementation: _Noreturn would get defined to nothing; the code > would be valid, but the C11 _Noreturn function specifier would not > be used. Correct. _Noreturn is an optimization hint; your code will still function correctly if the specifier is not present. The gnulib choice to define it away on problematic systems is intentional. -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf