If you are trying to achieve microsoft VC++ code compatibility, (which I hope you are), there are at least 2 issues that need to be dealt with to be able to compile windows code.
- unsigned 64-bit constants need to be ended with ULL for unsigned GNU compatibility, signed is LL for GNU compatibility, Ui64 for unsigned microsoft, i64 for signed microsoft.
- basetsd.h should not have to be included at all. the issue here is the __int64 type. it should be a built-in type. in fact, there should be __int8, __int16, __int32, and especially __int64 types. you can use the unsigned keyword along with these to make them unsigned. these are microsoft basic data types. you don't have to include windows.h in VC++ to use these. they are used as basic data types in a LOT of things in windows structures. I don't know for sure if there is a __int128 yet or not with VC++ 2010.
C:\prj\test\mingw-w64\__int64>goto neitherskipgw
__int64.cpp:2:15: error: invalid suffix "i8" on integer constant
__int64.cpp:3:17: error: invalid suffix "i16" on integer constant
__int64.cpp:4:17: error: invalid suffix "i32" on integer constant
__int64.cpp:5:17: error: invalid suffix "i64" on integer constant
__int64.cpp:6:19: error: invalid suffix "i128" on integer constant
__int64.cpp: In function 'int main()':
__int64.cpp:2: error: '__int8' was not declared in this scope
__int64.cpp:2: error: expected ';' before 'i8'
__int64.cpp:3: error: '__int16' was not declared in this scope
__int64.cpp:3: error: expected ';' before 'i16'
__int64.cpp:4: error: '__int32' was not declared in this scope
__int64.cpp:4: error: expected ';' before 'i32'
__int64.cpp:5: error: '__int64' was not declared in this scope
__int64.cpp:5: error: expected ';' before 'i64'
__int64.cpp:6: error: '__int128' was not declared in this scope
__int64.cpp:6: error: expected ';' before 'i128'
__int64.cpp:7: error: 'i128' was not declared in this scope
__int64.cpp:7: error: 'i64' was not declared in this scope
__int64.cpp:8: error: 'i32' was not declared in this scope
__int64.cpp:9: error: 'i16' was not declared in this scope
__int64.cpp:10: error: 'i8' was not declared in this scope
Volume in drive C is samsung 2000
Volume Serial Number is 783C-0FA9
Directory of C:\prj\test\mingw-w64\__int64
File Not Found
C:\prj\test\mingw-w64\__int64>type __int64.cpp
int main(void) {
__int8 i8=1i8;
__int16 i16=2i16;
__int32 i32=3i32;
__int64 i64=4i64;
__int128 i128=5i128;
i128 += i64;
i128 += i32;
i128 += i16;
i128 += i8;
return i128;
}
C:\prj\test\mingw-w64\__int64>
I don't know if microsoft defines i8, i16, i32 or i128 as part of a constant like U or L. I just don't remember, I would have to download the latest microsoft VC++ express compiler and try it.
but I know a VC++ microsoft compiler chokes on an __int64 type using anything but i64 or U or Ui64 or nothing in a constant.
and I don't know if __int128 is a type yet (I hope it is, it should be).
point is,
__int8 should be defined in g++ and gcc.
__int16 should be defined in g++ and gcc.
__int32 should be defined in g++ and gcc.
__int64 should be defined in g++ and gcc.
not sure about __int128 yet. would have to test with the 2010 express compiler.
I should not have to do this:
#if defined(__MINGW32__)
#include <windows.h>
#include <basetsd.h>
#endif
these are the compiler errors I get with g++ mingw-w64.
this shouldn't be.
please fix. thanks.
This is a problem with gcc itself not with any of the mingw projects, therefore I can only suggest that you take this as an enhancement request to the gcc developers. However, as mentioned on the mailing list before, I am not sure that it would be readily accepted by the gcc developers.
As for not having to include things for mingw: Instead of doing
#if defined(__MINGW32__)
#include <windows.h>
#include <basetsd.h>
#endif
you can do:
#if defined(__MINGW32__)
#include <_mingw.h>
#endif
... unless I am missing something.