Opened 14 years ago
Closed 14 years ago
#2156 closed patch (fixed)
fixes for Windows - MinGW gcc 4.4.0 compiler
Reported by: | smizuno | Owned by: | nobody |
---|---|---|---|
Priority: | minor: annoyance | Milestone: | Version 1.4.0 |
Component: | Build/Install | Version: | Trunk |
Keywords: | MinGW gcc 4.4 | Cc: | |
Must Fix for Release: | No | Platform: | Windows |
Platform Version: | Awaiting user input: | no |
Description
I have tried compiling QGIS using MinGW with its now current gcc 4.4.0 compiler. There were 2 errors about undefined types and 1 warning that occurred when using gcc 4.4.0.
files affected:
src/core/pal/pal.h: The error is caused by a missing time.h that is included by cwchar in the earlier version of the standard C++ headers and isn't included by the current version. I in noticed in pal.h that there is a test for _MSC_VER which includes the standard C header time.h.
Using this header allowed MinGW to compile OK. However, I realized that the C++ header is what should be included, not the underlying C header, so my patch removes the test for _MSC_VER and just includes the C++ header ctime. There should not be a problem if ctime has been included previously.
src/core/qgssearchstringparser.yy: The error in this file is caused by missing stdlib.h for similar reasons as in pal.h (bits/stl_algobase.h used to include cstdlib). I have added a line to include the C++ standard header cstdlib.
src/app/main.cpp: A warning about _fmode redeclared without dllimport attribute:... occurs in this file. This is because _fmode is being declared and initialized in the module. It is already declared extern in a header so just need to set its value. The proper way is to set _fmode in main() as is done (with _set_fmode() ) when MSVC is the compiler.
Also, the logic for whether MSVC or other (MinGW) is the compiler is somewhat confusing, so I have changed the #ifndef _MSC_VER near the top to #else to be part of the preceding #ifdef _MSC_VER. And the #undef _fmode isn't necessary with MinGW, as far as I can tell, so that was removed. I also added an enclosing #ifdef WIN32 in main() for the MSVC/MinGW statements. The statements used with MSVC were not changed.
I have tested these changes with MinGW/gcc 3.4.5 as well and found no issues.
MinGW/gcc 4.4.0 fixes (base is r11901)