Mail Archives: djgpp/2012/07/22/12:00:21
<rugxulo AT gmail DOT com> wrote in message
news:b1f8c389-45f4-43e4-9056-62fc50fc9462 AT googlegroups DOT com...
> On Friday, July 20, 2012 6:20:19 PM UTC-5, Rod Pemberton wrote:
...
> > It's \\ not // for C++ comments...
>
> It's not \\ but indeed // for C99 and C++. Granted, some languages
> might allow this. I know you like Forth, [...]
>
Sorry, you and the OP are correct. C's are both the same direction. Too
much Forth lately, I guess...
C uses // for full line comments and /* ... */ for delimited comments.
Forth uses \ for full line comments and ( ... ) for delimited comments.
I do the same if I'm using NASM alot too, i.e., attempt to use
"%if" instead of "#if" etc for C.
> I think you woke up on the wrong side of the bed. :-)
Actually, it was "late" for me when I wrote it, but I did reread it when I
woke, just prior to posting. So, I missed it, not once, but twice ...
> Actually, on another note, I'm now vaguely curious about
> sizeof(struct) and how alignment (esp. C11 stdalign crud
> or whatever) would affect that.
I'd assume alignment would increase the physical size. I don't know if it
increases sizeof()'s value though. I would think not... I would think that
C should only return the total size for C elements and not padding or
alignment. I can consult a book if you want. I generally try to avoid
using sizeof(). However, it's sometimes convenient to get the size for
procedures like malloc(), fread(), memset(). Sometimes they'll be passed
values or buffers whose size is unknown at compile time, e.g., malloc().
For most situations, padding or alignment doesn't matter. You're accessing
the struct's C elements. You don't need to access padding. So, if there is
space inbetween, it's unimportant. However, if the struct needs to be
without padding or a specific alignment, you can pack it. Most C compilers
have an extension, or sometimes few, to allow packing and aligning structs.
> http://en.wikipedia.org/wiki/Sizeof
>
I should probably read that, and the book's section too. Although,
I won't unless pressed. :-)
Rod Pemberton
- Raw text -