sizeof

G

goose

Andrew said:
x += (sizeof q) - 3;

would be an appropriate use of parentheses in this situation, IMHO, and

Not really, see Frederick Gothams post upthread on the precedence
rules for sizeof.

goose,
 
A

Andrew Poelstra

Not really, see Frederick Gothams post upthread on the precedence
rules for sizeof.

My point was for human readability; it's very easy to see that q goes
with sizeof and not with -, whereas without the parentheses one might
have to stop and think for a second.
 
E

ena8t8si

Andrew said:
x += (sizeof q) - 3;

would be an appropriate use of parentheses in this situation, IMHO, and
would likely be the form I'd use. (I very rarely use sizeof outside of
malloc and friends, though.)

Not guaranteed to produce the same result.
 
H

Hallvard B Furuseth

Joe said:
How many messages in this thread?

One more, now that you've posted one. Your point?
Assuming y an expression, 'sizeof y' is correct. sizeof(y) is to be
shunned.

Well, it's sure nice to have an authority on the matter step forward
with the right answer, so those of us with mere opinions can quit
wasting our time.
It makes sizeof look like a function. It is not.

Assuming T a type, 'sizeof (T)' is to be preferred over 'sizeof(T)'
which looks like a function. 'sizeof T' is an error of course.

So do macros what?

I meant that macro calls - or is it called macro invocations? - also
look like function calls. UPPERCASE_MACRO() helps but lowercase ones
exists, including some in the standard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top