问题
I am trying to use cywin to get some linux code building on a win32 machine.
I get the following VS.net 2003 error in ym compiler:
"c:\cygwin\usr\include\sys_types.h(15): error C2144: syntax error : '__int64' should be preceded by ';' "
and
c:\cygwin\usr\include\sys_types.h(15): error C2501: 'extension' : missing storage-class or type specifiers
The code line is
__extension__ typedef long long _off64_t;
Obviously I am missing something here but I have never used cygwin before and this is killing me.
I want to be able to at least compile my CPP files on my win32 machine for a few reasons.
(this is just the first two errors of hundreds it looks like)
thanks, tim
EDIT:
the simple workaround I have chosen as the answer - though I do understand that is not as complete or as desirable as using gcc to compile... This is a quick and dirty compilation so that I can use my familiar tools before trying to integrate with linux machines. (oh the joys of cross-platform development)
I've voted up each of those answers so far and appreciate the help)
回答1:
I think that the extension macro may not be defined. You may want to do a text search on your cygwin header dir to see if this is the case. If so, make sure that you header search path is defined correctly, etc.
回答2:
I could be wrong, but the cygwin headers could be made specifically for compiling using the cygwin gcc, not visual studio. Try compiling using gcc/g++ in cygwin.
EDIT: I may be possible to use Visual Studio, this page (for another project) seems to imply that you can compile something with vc++/cygwin. http://opensg.vrsource.org/trac/wiki/BuildVS2005Cygwin.
You may want to check it out.
EDIT2: Also See: http://www.coin-or.org/OS/documentation/node14.html
EDIT3: I would guess that the best coarse of action would be to make sure that visual studio searches the standard windows paths first. So if there is a system <sys/types.h>
, that may be preferred over the cygwin version.
回答3:
The __extension__
keyword is a gcc extension to denote code that uses gcc extensions (in this case long long
), so it doesn't blow up in pedantic mode. If you can, try compiling your code with gcc.
回答4:
In C++, any name preceded (or containing) a double underscore is a name reserved for a particular implementation, in this case GNU C++. MS C++ will use other names. Bottom line - you can't compile g++ sources with MS C++, or vice versa, if the sources use such names.
来源:https://stackoverflow.com/questions/579556/cygwin-compile-error-in-sys-types-h