As seen here http://source.winehq.org/source/include/winnt.h#L152, we seem to be going through a lot of trouble to enable anonymous structs and unions for those compilers that support it. Why do this, especially when we need to name them anyway for those that don't?
My reason for asking is that I'm doing a casual ANSI sweep of the code, and anonymous unions are causing problems (they're not allowed). I could just put in a test for __STRICT_ANSI__ and disable them if found, but that feels like gaming the system, and it's not a standard macro anyway. The best way (other than just naming all the structs/unions) is to test for __STDC__, but GCC includes that one even when not using -ansi mode.
Thoughts?
Joel Parker wrote:
As seen here http://source.winehq.org/source/include/winnt.h#L152, we seem to be going through a lot of trouble to enable anonymous structs and unions for those compilers that support it. Why do this, especially when we need to name them anyway for those that don't?
For compatibility with source code without NONAMELESSUNIONS/STRUCTS that is compiled with compilers that support anonymous structs and unions.
My reason for asking is that I'm doing a casual ANSI sweep of the code, and anonymous unions are causing problems (they're not allowed). I could just put in a test for __STRICT_ANSI__ and disable them if found, but that feels like gaming the system, and it's not a standard macro anyway. The best way (other than just naming all the structs/unions) is to test for __STDC__, but GCC includes that one even when not using -ansi mode.
Thoughts?
I have never been a fan of changing code for the benefit of enabling obscure compiler options that don't help to fix bugs, but I guess the check for __STRICT_ANSI__ is the best.
Joel Parker wrote:
As seen here http://source.winehq.org/source/include/winnt.h#L152, we seem to be going through a lot of trouble to enable anonymous structs and unions for those compilers that support it. Why do this, especially when we need to name them anyway for those that don't?
My reason for asking is that I'm doing a casual ANSI sweep of the code,
I doubt that is useful. If you do that i would at least check for C99. There is no point for checking for compatibility with an old standard just for the sake of being compliant. There is a point though to keep compliance with an old existing compiler that people still use. That is for Wine gcc-2.95.
and anonymous unions are causing problems (they're not allowed). I could just put in a test for __STRICT_ANSI__ and disable them if found, but that feels like gaming the system, and it's not a standard macro anyway. The best way (other than just naming all the structs/unions) is to test for __STDC__, but GCC includes that one even when not using -ansi mode.
Thoughts?
See above.
bye michael