I have a vague memory that we discussed this idea during development of
the C99 standard, but rejected it. However, I can't recall why (though
the most likely reason is lack of utility).
--
Clive D.W. Feather | Home: <cl...@davros.org>
Mobile: +44 7973 377646 | Web: <http://www.davros.org>
Please reply to the Reply-To address, which is: <cl...@davros.org>
--
comp.lang.c.moderated - moderation address: cl...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
My vague recollection was that we couldn't think of a system where
sizeof(type) wouldn't be Good Enough. So, lack of marginal utility.
I could be totally wrong, my memory's not awesome.
-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
sizeof(type) would be good enough for scalar types, but for large
structs it would be useful to be able to determine that, say, a
1024-byte struct only needs 4-byte alignment.
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Why would it?
In other words, suppose that the Standard included a pseudo-function:
size_t alignmentof (type t);
What could you portably do with it that you can't portably do without
it?
--
Clive D.W. Feather | Home: <cl...@davros.org>
Mobile: +44 7973 377646 | Web: <http://www.davros.org>
Please reply to the Reply-To address, which is: <cl...@davros.org>
Possibly implement your own special-purpose memory allocation routine which
works within larger blocks but has performance characteristics suited to
a particular environment or usage -- in which you might want to know, having
stashed a (foo_t) at the beginning of a block, how much padding you need
between it and a subsequent (bar_t).
I can't imagine there's much overlap between the set of people who think
they need to do this, and the set of people who can actually outperform
a modern malloc implementation, but perhaps there's some.
-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
Well, there are the people who actually *write* modern malloc
implementations. They can certainly use implementation-specific
tricks, but surely adding something like alignmentof to the language
would make their jobs easier.
Which is probably at least part of the reason that the "alignof"
keyword is being added to C201X; see n1425.pdf.
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"