Thread overview |
---|
August 22, 2008 [Issue 2302] New: offsetof property not working properly | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2302 Summary: offsetof property not working properly Product: D Version: 1.030 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: malagana15@yahoo.es Please check these 2 short posts on the newsgroup. You'll notice that offsetof property is not working the way it should or the way it is described in the doc: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=13576 http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=13579 Please reply to know it's a bug. DMD 1.030 Thanks for your support. -- |
August 26, 2008 [Issue 2302] offsetof property not working properly | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2302 ------- Comment #1 from malagana15@yahoo.es 2008-08-26 12:46 ------- Please note that this issue is related to offsetof for structures. Offsetof for classes have had many bugs but have been fixed. The thing here is that offsetof for a structure can only be called from a static function and not from anywhere, so, porting some C code to D modules is impossible or full of workarounds. -- |
August 27, 2008 [Issue 2302] offsetof property not working properly | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2302 ------- Comment #2 from malagana15@yahoo.es 2008-08-27 13:39 ------- I'm posting a few workarounds to get offsetof to work on structures: 1) Create a static function to return the offset, how you do it will depend on your code. This seems to work fine. 2) Use this template i did, it compiles ok but needs more testing, i call it from a static enviroment and works perfect: (This try to simulate the Win32 macro FIELD_OFFSET) template FIELD_OFFSET(alias T) { const uint FIELD_OFFSET = T.offsetof; } Example: module x; const uint DIMOFS_X = FIELD_OFFSET!(DIMOUSESTATE.lX); const uint DIMOFS_BUTTON1 = FIELD_OFFSET!(DIMOUSESTATE.rgbButtons) + 1; struct DIMOUSESTATE { long lX; long lY; long lZ; byte rgbButtons[4]; } -- |
May 27, 2009 [Issue 2302] offsetof property not working properly | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2302 Vladimir <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |thecybershadow@gmail.com Resolution| |DUPLICATE --- Comment #3 from Vladimir <thecybershadow@gmail.com> 2009-05-27 05:22:20 PDT --- *** This issue has been marked as a duplicate of issue 899 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation