[QGIS-trac] Re: [Quantum GIS] #234: ISO C++ forbids casting between pointer-to-function and pointer-to-object

Quantum GIS qgis at qgis.org
Sat Aug 23 12:10:35 EDT 2008


#234: ISO C++ forbids casting between pointer-to-function and pointer-to-object
----------------------------------------------------+-----------------------
        Reporter:  mloskot                          |         Owner:  gsherman                
            Type:  enhancement                      |        Status:  closed                  
        Priority:  minor: annoyance or enhancement  |     Milestone:  Version 1.0.0           
       Component:  Build/Install                    |       Version:  HEAD                    
      Resolution:  wontfix                          |      Keywords:  casting pointer function
Platform_version:  Ubuntu 6.06                      |      Platform:  Debian                  
        Must_fix:  No                               |   Status_info:  0                       
----------------------------------------------------+-----------------------
Changes (by jef):

  * status:  new => closed
  * resolution:  => wontfix

Comment:

 Replying to [comment:13 mloskot]:
 > Folks, as I see dlsym is used indirectly but through QLibrary::resolve.
 The http://doc.trolltech.com/4.0/qlibrary.html#resolve Qt documentation]
 says:
 >
 >  ''The symbol must be exported as a C function from the library.''
 >
 > Does it happen in QGIS?

 Sure, otherwise resolve() wouldn't find the function.  That's what
 QGISEXPORT is for.

 > In fact, it would solve the problem I've reported here.

 No, it wouldn't.  The root of the problem is not QGIS, it's
 QLibrary::resolve() and in turn dlsym() (and maybe GetProcAddress on
 Windows, too).  Those return void * and that result is impossible to
 legally cast to a function pointer in C++.   Nevertheless that cast works
 fine, otherwise dlsym() would be useless.

 If they'd return void (*)() there wouldn't be a problem at all.  So anyone
 doing dynamic loading with C++ should have that problem at some point.

 Although there might be architectures that use different memory and
 function pointers on which such a cast would be a problem (maybe there are
 embedded systems like that; using different memory for data and code), I
 doubt that those are a possible target for Qt.   And I doubt that one
 would find dlsym() there.

 The warnings just tell us, that our code wouldn't work there. And the
 tricks just make that warning go away.  The point of it: compile in
 maximum warning level, get all the good warnings and not that one warning,
 that we believe doesn't apply to any architecture we possibly target.

 And rereading the comments above - which I should have done in the first
 place - that was also your conclusion on 10/14/06.  I think there's
 nothing we can do about it then simply wait.  I take the liberty to close
 this bug as the problem will solve itself at some point, when we port to a
 Qt version, that supports the dlsym(), that does it right.

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/234#comment:14>
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