Clang and windows headers

Angelo Graziosi angelo.graziosi@alice.it
Thu Jan 10 16:20:00 GMT 2013


Trying to compile a C++ source file including windows.h header with 
clang++, fails with

   #error Must define a target architecture


For example,

$ cat foo.cxx
#include <windows.h>

int main()
{
   return 0;
}

$ clang++ -c foo.cxx -o foo.o
In file included from foo.cxx:1:
In file included from /usr/include/w32api/windows.h:69:
In file included from /usr/include/w32api/windef.h:139:
/usr/include/w32api/winnt.h:375:2: error: Must define a target architecture.
#error Must define a target architecture.
  ^
/usr/include/w32api/winnt.h:2410:7: error: unknown type name 'PCONTEXT'; 
did you
       mean '_CONTEXT'?
       PCONTEXT ContextRecord;
       ^
/usr/include/w32api/excpt.h:84:96: note: '_CONTEXT' declared here
   ..._EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
                                        ^
In file included from foo.cxx:1:
In file included from /usr/include/w32api/windows.h:69:
In file included from /usr/include/w32api/windef.h:139:
/usr/include/w32api/winnt.h:2410:16: error: field has incomplete type 
'_CONTEXT'
       PCONTEXT ContextRecord;
                ^
/usr/include/w32api/excpt.h:84:96: note: forward declaration of '_CONTEXT'
   ..._EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
                                        ^
In file included from foo.cxx:1:
In file included from /usr/include/w32api/windows.h:69:
In file included from /usr/include/w32api/windef.h:139:
/usr/include/w32api/winnt.h:5668:25: error: variable has incomplete type 
'void'
     NTSYSAPI VOID NTAPI RtlCaptureContext(PCONTEXT ContextRecord);
                         ^
/usr/include/w32api/winnt.h:5668:43: error: use of undeclared identifier
       'PCONTEXT'
     NTSYSAPI VOID NTAPI RtlCaptureContext(PCONTEXT ContextRecord);
                                           ^
In file included from foo.cxx:1:
In file included from /usr/include/w32api/windows.h:70:
/usr/include/w32api/winbase.h:611:11: error: unknown type name 
'PCONTEXT'; did
       you mean '_CONTEXT'?
   typedef PCONTEXT LPCONTEXT;
           ^
/usr/include/w32api/excpt.h:84:96: note: '_CONTEXT' declared here
   ..._EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
                                        ^
In file included from foo.cxx:1:
In file included from /usr/include/w32api/windows.h:70:
/usr/include/w32api/winbase.h:1375:67: error: unknown type name 
'CONTEXT'; did
       you mean '_CONTEXT'?
   ...WINAPI SetThreadContext(HANDLE hThread,CONST CONTEXT *lpContext);
                                                   ^
/usr/include/w32api/excpt.h:84:96: note: '_CONTEXT' declared here
   ..._EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
                                        ^
7 errors generated.


Really I have seen this the first time trying to build the next release 
of ROOT (i.e. source from svn; the main page for ROOT is : 
http://root.cern.ch).

Indeed now ROOT uses clang tools to build (GCC is used to bootstrap 
ROOT's patched version of CLANG...). Nevertheless the same errors occurs 
using Cygwin's CLANG as the above simple test case shows...


Ciao,
Angelo.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list