* wspiapi.h uses _N conflicting with ctype.h
@ 2015-08-03 11:17 Michael Enright
2015-08-03 13:46 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Michael Enright @ 2015-08-03 11:17 UTC (permalink / raw)
To: cygwin
Here's a reduction of a problem I had compiling v8:
#include <ctype.h>
#include "wspiapi.h"
char array[5];
__wspiapi_countof_helper(array);
The reduction isn't realistic but the problem is real.
On one hand, ctype.h uses _N and it is within its "rights" to do so as
ctype.h is part of the standard library. The statement that uses _N
initially is "#define _N 04", so _N enters the global space of defined
macros.
On the other hand the template __wspiapi_countof_helper uses _N as the
name of one of its parameters. This usage is in the domain of strings
that can be interpreted as references to macros by the preprocessor,
so the _N gets interpreted by the post-preprocessor phases as 04,
causing some distress.
So... the win32 headers are free to use
leading-underscore-capital-letter symbols or no?
Anyway, how can this be addressed?
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: wspiapi.h uses _N conflicting with ctype.h
2015-08-03 11:17 wspiapi.h uses _N conflicting with ctype.h Michael Enright
@ 2015-08-03 13:46 ` Corinna Vinschen
2015-08-03 22:45 ` JonY
0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2015-08-03 13:46 UTC (permalink / raw)
To: cygwin; +Cc: JonY
[-- Attachment #1: Type: text/plain, Size: 1575 bytes --]
On Aug 3 04:17, Michael Enright wrote:
> Here's a reduction of a problem I had compiling v8:
>
> #include <ctype.h>
> #include "wspiapi.h"
> char array[5];
> __wspiapi_countof_helper(array);
>
> The reduction isn't realistic but the problem is real.
>
> On one hand, ctype.h uses _N and it is within its "rights" to do so as
> ctype.h is part of the standard library. The statement that uses _N
> initially is "#define _N 04", so _N enters the global space of defined
> macros.
>
> On the other hand the template __wspiapi_countof_helper uses _N as the
> name of one of its parameters. This usage is in the domain of strings
> that can be interpreted as references to macros by the preprocessor,
> so the _N gets interpreted by the post-preprocessor phases as 04,
> causing some distress.
>
> So... the win32 headers are free to use
> leading-underscore-capital-letter symbols or no?
It's unfortunate, but with their right, just like the std headers.
> Anyway, how can this be addressed?
The best result would be if you (or we) could convince the mingw-w64
guys not to use _N. Jon? Any chance you could apply a patch to use
_n with lower case n?
For the time being, you can push/pop the clashing macros prior to
including the problematic header(s):
#include <ctype.h>
#pragma push_macro ("_N")
#undef _N
#include <wspiapi.h>
#pragma pop_macro("_N")
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: wspiapi.h uses _N conflicting with ctype.h
2015-08-03 13:46 ` Corinna Vinschen
@ 2015-08-03 22:45 ` JonY
0 siblings, 0 replies; 3+ messages in thread
From: JonY @ 2015-08-03 22:45 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 498 bytes --]
On 8/3/2015 21:46, Corinna Vinschen wrote:
>
> The best result would be if you (or we) could convince the mingw-w64
> guys not to use _N. Jon? Any chance you could apply a patch to use
> _n with lower case n?
>
> For the time being, you can push/pop the clashing macros prior to
> including the problematic header(s):
>
> #include <ctype.h>
> #pragma push_macro ("_N")
> #undef _N
> #include <wspiapi.h>
> #pragma pop_macro("_N")
>
>
OK, I'll see to this.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-03 22:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03 11:17 wspiapi.h uses _N conflicting with ctype.h Michael Enright
2015-08-03 13:46 ` Corinna Vinschen
2015-08-03 22:45 ` JonY
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).