[QGIS-trac] [Quantum GIS] #2156: fixes for Windows - MinGW gcc 4.4.0 compiler

Quantum GIS qgis at qgis.org
Fri Nov 27 10:24:18 EST 2009


#2156: fixes for Windows -  MinGW gcc 4.4.0 compiler
--------------------------------+-------------------------------------------
   Reporter:  smizuno           |              Owner:  nobody       
       Type:  patch             |             Status:  new          
   Priority:  minor: annoyance  |          Milestone:  Version 1.4.0
  Component:  Build/Install     |            Version:  HEAD         
   Keywords:  MinGW gcc 4.4     |   Platform_version:               
   Platform:  Windows           |           Must_fix:  No           
Status_info:  0                 |  
--------------------------------+-------------------------------------------
 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.

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/2156>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list