[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] stdnoreturn: new module
From: |
Eric Blake |
Subject: |
Re: [PATCH] stdnoreturn: new module |
Date: |
Tue, 28 Feb 2012 05:55:33 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 |
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 address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [PATCH] stdnoreturn: new module, Paul Eggert, 2012/02/24
- Re: [PATCH] stdnoreturn: new module, Bruno Haible, 2012/02/27
- Re: [PATCH] stdnoreturn: new module, Bruno Haible, 2012/02/28
- Re: [PATCH] stdnoreturn: new module, Paul Eggert, 2012/02/28
- Re: [PATCH] stdnoreturn: new module, Eric Blake, 2012/02/28
- Re: [PATCH] stdnoreturn: new module, Bruno Haible, 2012/02/28
- Re: [PATCH] stdnoreturn: new module, Paul Eggert, 2012/02/29