mercredi 4 mars 2015

Porting component that uses Wtypes.h from Visual Studio to Mingw GCC

I am currently in the process of porting a component from Visual Studio to Mingw GCC. The component builds fine in Visual Studio 2008 however when it comes to Mingw I am initially getting the following errors. These errors seem to be coming from a header file called Wtypes.h which is located in "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\.". Now here are some of the errors that I have come across:



..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\winnt.h|81|error: #error "No Target Architecture"|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\wtypes.h|1115|error: pasting "/" and "/" does not give a valid preprocessing token|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\oaidl.h|445|note: in expansion of macro '_VARIANT_BOOL'|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\wtypes.h|1115|error: pasting "/" and "/" does not give a valid preprocessing token|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\oaidl.h|460|note: in expansion of macro '_VARIANT_BOOL'|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\wtypes.h|1115|error: pasting "/" and "/" does not give a valid preprocessing token|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\propidl.h|313|note: in expansion of macro '_VARIANT_BOOL'|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\intsafe.h|142|warning: "INT_MIN" redefined [enabled by default]|
C:\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.2\include-fixed\limits.h|118|note: this is the location of the previous definition|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\intsafe.h|144|warning: "LONG_MIN" redefined [enabled by default]|
C:\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.2\include-fixed\limits.h|129|note: this is the location of the previous definition|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\intsafe.h|170|warning: "INT_MAX" redefined [enabled by default]|
C:\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.2\include-fixed\limits.h|120|note: this is the location of the previous definition|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\intsafe.h|172|warning: "UINT_MAX" redefined [enabled by default]|
C:\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.2\include-fixed\limits.h|124|note: this is the location of the previous definition|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\intsafe.h|174|warning: "LONG_MAX" redefined [enabled by default]|
C:\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.2\include-fixed\limits.h|131|note: this is the location of the previous definition|
..\..\..\..\..\Program Files\Microsoft SDKs\Windows\v6.0A\Include\intsafe.h|175|warning: "ULONG_MAX" redefined [enabled by default]|
C:\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.2\include-fixed\limits.h|135|note: this is the location of the previous definition|


My guess is that some of these errors are because of preprocessor directives. For instance. The `Wtypes.h has the following code in it



#ifdef __cplusplus
#if _MSC_VER >= 1300
#define TYPE_ALIGNMENT( t ) __alignof(t)
#endif
#else
#define TYPE_ALIGNMENT( t ) \
FIELD_OFFSET( struct { char x; t test; }, test )
#endif

#if defined(_WIN64)

#if defined(_AMD64_)
#define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( DWORD )
#elif defined(_IA64_)
#define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( DWORD ) ? \
TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( DWORD ))
#else
#error "No Target Architecture"
#endif


My question is how can I resolve the No target Architecture Issue here and is there a way for me to figure out what defines are being included when visual studio attemepts to build this component. Any suggestions on tackling this issue would be appreciated.


Aucun commentaire:

Enregistrer un commentaire