extra compile warnings

View: New views
3 Messages — Rating Filter:   Alert me  

extra compile warnings

by Paul Harris-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I like to compile with these warnings enabled for GCC:

-Wall -Wmissing-declarations -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align

Unfortunately, its very annoying to compile FOX because of these warnings:
FXObject.h:165: warning: cast from type ‘const FX::FXObject*’ to type ‘FX::FXObject*’ casts away constness
FXRex.h:108: warning: cast from type ‘const FX::FXint*’ to type ‘FX::FXint*’ casts away constness

Can we use a const_cast<>() to kill off these warnings and improve the code?

thanks,
Paul


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: extra compile warnings

by Jeroen van der Zijp-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tuesday 03 November 2009, Paul Harris wrote:
> -Wall -Wmissing-declarations -Wwrite-strings -Wpointer-arith -Wcast-qual
> -Wcast-align


I have fixed the warnings (it appears):

1) In FXObject.h, change line:

   friend FX::FXStream& operator<<(FX::FXStream& store,const classname* obj){return store.saveObject((FX::FXObjectPtr)(obj));} \

to:

   friend FX::FXStream& operator<<(FX::FXStream& store,const classname* obj){return store.saveObject((const FX::FXObject*)(obj));} \

   (There are two such lines)

   The riginal line of code was actually wrong to cast to FXObject*, it should have preserved the
   const-ness since the parameter of operator<<() is actually taking const FXObject*.


2) In FXRex, I changed the default ctor to a non-inlined version to take care of the problem.
   Internally, I still need to see if const_cast< > will pass through all the compilers; if it
   will then I'll probably use it anywhere.

   For now, you can replace line

   FXRex():code((FXint*)fallback){}

with:

   FXRex():code(const_cast<FXint*>(fallback)){}  

or:

   FXRex():code((FXint*)(void*)fallback){}

   Either one will make the error go away.


Thanks for the info, BTW.  It found a minor problem in the FXDECLARE implementation.


                - Jeroen

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: extra compile warnings

by Paul Harris-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



2009/11/5 Jeroen van der Zijp <jvdzijp@...>
On Tuesday 03 November 2009, Paul Harris wrote:
> -Wall -Wmissing-declarations -Wwrite-strings -Wpointer-arith -Wcast-qual
> -Wcast-align


I have fixed the warnings (it appears):



snip

thanks, those changes removed the warnings :)

 


Thanks for the info, BTW.  It found a minor problem in the FXDECLARE implementation.



glad to hear it :)  thats why I like those extra warnings.

cheers
Paul


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users