Portability issues

Anonymous unions/structs

Anonymous structs and unions support depends heavily on the compiler. The best support is provided by gcc/g++ 2.96 and later. But these versions of gcc come from the development branch so you may want to hold off before using them in production. g++ 2.95 supports anonymous unions but not anonymous structs and gcc 2.95 supports neither. Older versions of gcc/g++ have no support for either. since it is anonymous unions that are the most frequent in the windows headers, you should at least try to use gcc/g++ 2.95.

But you are stuck with a compiler that does not support anonymous structs/unions all is not lost. The Wine headers should detect this automatically and define NONAMELESSUNION / NONAMELESSSTRUCT. Then any anonymous union will be given a name u or u2, u3, etc. to avoid name clashes. You will then have to modify your code to include those names where appropriate.

The name that Wine adds to anonymous unions should match that used by the Windows headers. So all you have to do to compile your modified code in Windows is to explicitly define the NONAMELESSUNION macro. Note that it would be wise to also explicitly define this macro on in your Unix makefile (Makefile.in) to make sure your code will compile even if the compiler does support anonymous unions.

Things are not as nice when dealing with anonymous structs. Unfortunately the Windows headers make no provisions for compilers that do not support anonymous structs. So you will need to be more subtle when modifying your code if you still want it to compile in Windows. Here's a way to do it:

#ifdef WINELIB
#define ANONS .s
#else
#define ANONS
#endif

. . .

{
SYSTEM_INFO si;
GetSystemInfo(&si);
printf("Processor architecture=%d\n",si ANONS .wProcessorArchitecture);
}
      

You may put the #define directive directly in the source if only few files are impacted. Otherwise it's probably best to put it in one of your project's widely used headers. Fortunately usage of an anonymous struct is much rarer than usage of an anonymous union so these modifications should not be too much work.