From: SourceForge.net <no...@so...> - 2006-08-09 19:42:47
|
Bugs item #1518273, was opened at 2006-07-06 19:22 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1518273&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: C-Front End Group: None Status: Open Resolution: None Priority: 5 Submitted By: Stas Sergeev (stsp) Assigned to: Nobody/Anonymous (nobody) Summary: good code rejected with strange error Initial Comment: Hi. The following code (attached) doesn't compile: --- #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER) struct e { unsigned char a; }; struct x { unsigned char b; struct e c[0]; }; unsigned char r(unsigned char n) { return offsetof(struct x, c[n]); } unsigned char main() { return r(5); } --- $ sdcc --std-sdcc99 off.c off.c:14: error 151: cannot use generic pointer <null> to initialize <null> ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2006-08-09 21:42 Message: Logged In: YES user_id=888171 Stas, According to the standard this macro should be defined in stddef.h so I put it there already 2 years ago. AFAIK it works perfectly. Only I used another pair of parentheses before taking the address. I would have to look up if your code should give the same result. Maarten ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1518273&group_id=599 |