🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

use of offsetof in gcc 3.4.x

Started by
1 comment, last by kunitoki 17 years, 9 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 ?
Advertisement
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

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