Gerald Pfeifer gerald@pfeifer.com writes:
This patch moves these into main() in main.c, which has several advantages:
- The asserts are only evaluated once, not for every #inclusion of request.h, which simplifies/speeds up the compilation.
It doesn't make any difference, that stuff is inside a #ifdef. Also it's auto-generated, so moving it manually won't help.
- More importantly, these were the only occurences of C_ASSERT at file level. By moving these at function level use thereof becomes consistent which will allow the fix from PATCH 2/2 to work at all.
C_ASSERT is supposed to work at the file level too.
On Mon, 11 May 2009, Alexandre Julliard wrote:
- More importantly, these were the only occurences of C_ASSERT at file level. By moving these at function level use thereof becomes consistent which will allow the fix from PATCH 2/2 to work at all.
C_ASSERT is supposed to work at the file level too.
The current implementation doesn't work with GCC 4.5 (or ISO C) and I failed to find any other way. :-(
Your point on this being autogenerated clearly is strong one -- either we need to change that generation or find a different way to implement C_ASSERT.
Any idea how to best approach this?
Gerald
Gerald Pfeifer gerald@pfeifer.com writes:
The current implementation doesn't work with GCC 4.5 (or ISO C) and I failed to find any other way. :-(
Your point on this being autogenerated clearly is strong one -- either we need to change that generation or find a different way to implement C_ASSERT.
Any idea how to best approach this?
I don't have gcc 4.5 to test this, but you could try using a function instead, something like this:
diff --git a/include/winnt.h b/include/winnt.h index abcc502..aaa4112 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -292,7 +292,7 @@ extern "C" { #if defined(_MSC_VER) # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] #elif defined(__GNUC__) -# define C_ASSERT(e) extern char __C_ASSERT__[(e)?1:-1] __attribute__((unused)) +# define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1]) #else # define C_ASSERT(e) #endif
On Mon, 11 May 2009, Alexandre Julliard wrote:
I don't have gcc 4.5 to test this, but you could try using a function instead, something like this:
diff --git a/include/winnt.h b/include/winnt.h index abcc502..aaa4112 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -292,7 +292,7 @@ extern "C" { #if defined(_MSC_VER) # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] #elif defined(__GNUC__) -# define C_ASSERT(e) extern char __C_ASSERT__[(e)?1:-1] __attribute__((unused)) +# define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1]) #else # define C_ASSERT(e) #endif
You are a clever man, Sir! :-)
It took me a bit, since incidently the GCC 4.5 development tree was broken wrt. Wine on Monday (I reported this bug upstream), but a build with your patch went through both with GCC 4.2.1 and GCC 4.5.0 (experimental) tonight.
I assume you will commit this now?
Thanks, Gerald