Advertisement

use of offsetof in gcc 3.4.x

Started by August 15, 2006 08:23 AM
1 comment, last by kunitoki 18 years, 2 months ago
i'm completing the initial port of angeljuice for linux, all is quite good except that i get a compiler warning that i'm trying to use the offsetof macro with a non-static member. something like for example:

r = engine->RegisterObjectProperty("MouseEvent", "int x", offsetof(MouseEvent,x)); jassert( r >= 0 );

// In static member function `static void ejuce::asMouseEvent::registerObjectType(asIScriptEngine*)':
// warning: invalid access to non-static data member `juce::MouseEvent::x' of NULL object

also when trying to execute that piece of code which access the memeber of a class (non static) i get a segmentation fault. anyone have already this issue ? i mean, on windows there isn't this kind of problem probably because offsetof works differently. there is a way to obtain the offsetof macro work that way in gcc on linux ? (macosx's gcc is not reporting that warning nor crashing)... any ideas ?
I always get a compiler warning with the offsetof macro when I compile on Linux, but in all my tests it worked anyway. Never had any problem with accessing the members.

Unfortunately I do not have a solution for you. Perhaps you can rewrite the offsetof macro in some way to not cause the compiler warning?

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
hey andreas ! welcome back on track !
anyway i've understood how to use offsetof macro properly with static defined attributes...
thanx the same !

This topic is closed to new replies.

Advertisement