This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: using offsetof with g++


Michael Matz <matz@suse.de> writes:

[...]

| > Which is the reason of the basic question
| >   Why do you want to take the offsetof a non-POD?
| 
| For exactly the same reasons you want to apply offsetof() to a C
| struct. 

Well, if you're NOT using a C struct in the first place, then it means
you're doing something different from the reasons that push for a C
struct solution.

| Now you might ask further why someone would then want to make
| this a non-POD struct.  I gave also reasons for that.  That is, I can
| return with a question which has to be answered by people wanting to
| restrict offsetof():
| 
|    Why not allow offsetof on a nearly-POD?

you're free to return with that question; but I doubt it makes make a
step forward :-)  

The simple reason is that the general rule is not to make the language
an accumulation of work arounds nobody find no convincing reasons not
to have.  Rather, it is built as interconnected language constructs
that support sound programming styles.  If you can give sound answers
to the basic question, then I guess you'll make a step forward;
otherwise, I fear we'll just exchange mails with no real progress. 

| > It is not clear at all that an accumulation of work arounds to speicific
| > issues makes a simpler language to learn, use and implement.
| 
| Actually the users are surprised by some of the issues of offsetof(), so

Well, only users that have taken explicit steps to go behond what they
do with C offsetof with C datatypes are "surprised".  From my
perspective, that is not an indication the language is harder to learn.
For anything, it is an indication that native styles are not being
applied for one or other reasons.  Which again brings us back to the
basic question.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]