[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Avoid polluting cygwin namespace.
From: |
Bruno Haible |
Subject: |
Re: [PATCH] Avoid polluting cygwin namespace. |
Date: |
Tue, 6 Apr 2010 23:57:44 +0200 |
User-agent: |
KMail/1.9.9 |
Hi Eric,
> cygwin*)
> FAULT_CONTEXT='CONTEXT'
> - FAULT_CONTEXT_INCLUDE='#include <windows.h>'
> + # CONTEXT is defined in <windows.h>, but cygwin programs should not
> + # normally inspect the contents of CONTEXT, and the outright inclusion
> + # of <windows.h> pollutes the namespace.
> + FAULT_CONTEXT_INCLUDE='typedef struct _CONTEXT CONTEXT;'
This patch will break in two ways. I'm therefore opposed to it.
1) If the user does a #include <windows.h> before or after <sigsegv.h>,
he'll get a compilation error about a redefinition of a type.
error: redefinition of typedef ‘CONTEXT’
In C++, duplicated redundant typedefs are harmless, but not in C.
2) The users of libsigsegv need to access the field of the FAULT_CONTEXT.
That's what it is provided for, in the first place. For example, GNU clisp
does in src/spvw_sigsegv.d:
stackoverflow_context_t scp = (stackoverflow_context_t) arg1;
...
#if defined(WIN32_NATIVE) || defined(UNIX_CYGWIN32)
#ifdef I80386
if (scp) { setSTACK(STACK = (gcv_object_t*)(scp->Ebx)); }
#endif
#endif
This would be impossible if stackoverflow_context_t was an opaque type.
Instead, let's look more closely at the original problem: <windows.h>
defines WCHAR to a type, whereas grep/src/dfa.h uses it as an enum item.
The proposed workaround would not completely fix this problem: It would
solve it for Cygwin only, but not for mingw.
I would instead propose to add to dfa.h two lines:
/* <windows.h> defines WCHAR as a type. */
#undef WCHAR
When porting GNU clisp to Windows, for some time I avoided collisions
through #undefs like this, but after some amount of workarounds I ended
up simply choosing different identifiers. For example, WIDECHAR instead of
WCHAR.
Bruno
Re: fix for dfa when mixed with libsigsegv on Windows, Jim Meyering, 2010/04/06