c99 docs - any good?

M

mechanicfem

Lately I've been trying to learn about new stuff in c99 - today's topic
was/is variable length arrays.

As well as asking here, I've been 'doing the rounds' via Google, and
recently I found this article:

http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=215

It didn't help me much re my earlier question about using [*]

However, could someone tell me if this article is /reasonable/?

For example, the article mentions variadic macros, and __VA_ARGS__ -
however, I cannot find __VA_ARGS__ in the draft ISO spec I have, and so
I wonder if it's genuine?

I've also noted a couple of things that don't make sense that 'make me
wonder' about its quality, e.g.,

struct Employee
{
....
}

Followed by (note the missing /struct/)

Employee emp = {.ID=0, .record=NULL};

I guess my question really is - where can I find examples of /new/ c99
features, c/w readable descriptions?

x

Jo

P.S.

Just noticed that the article says that long long is at least 64 bits,
whereas the std says

The rank of long long int shall be greater than the rank of long int,
which
shall be greater than the rank of int, which shall be greater than the
rank of short
int, which shall be greater than the rank of signed char.

So, is there some error here too perhaps?
 
M

Michael Mair

Lately I've been trying to learn about new stuff in c99 - today's topic
was/is variable length arrays.

As well as asking here, I've been 'doing the rounds' via Google, and
recently I found this article:

http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=215

It didn't help me much re my earlier question about using [*]

However, could someone tell me if this article is /reasonable/?

For example, the article mentions variadic macros, and __VA_ARGS__ -
however, I cannot find __VA_ARGS__ in the draft ISO spec I have, and so
I wonder if it's genuine?

Search for "VA_ARGS" or "_VA_ARGS_" -- in order to make the number
of _ apparent, tiny spaces have been inserted in the PDF version.

I have not looked at the article, though. However, the cplusplus
in its name makes me wonder.
I've also noted a couple of things that don't make sense that 'make me
wonder' about its quality, e.g.,

struct Employee
{
...
}

Followed by (note the missing /struct/)

Employee emp = {.ID=0, .record=NULL};

Works only with an appropriate typedef.

I guess my question really is - where can I find examples of /new/ c99
features, c/w readable descriptions?

Not exactly what you are looking for, but a good starting
point:
http://david.tribble.com/text/cdiffs.htm
Just noticed that the article says that long long is at least 64 bits,
whereas the std says

The rank of long long int shall be greater than the rank of long int,
which
shall be greater than the rank of int, which shall be greater than the
rank of short
int, which shall be greater than the rank of signed char.

So, is there some error here too perhaps?

No. Learn to read the standard carefully. long long's guaranteed
maximum and minimum values are representable only if you use at least
64 bits.


Cheers
Michael
 
J

Jordan Abel

Not exactly what you are looking for, but a good starting
point:
http://david.tribble.com/text/cdiffs.htm

http://home.tiscalinet.ch/t_wolf/tw/c/c9x_changes.html is probably
better for the purpose of the question. At a glance, though, the page
you linked is a good analysis of the most recent chapter in the
compatibility and lack thereof between C and C++, though.

Where does it say that? I'm confused by "rank", does that mean they
can't all be the same width?
No. Learn to read the standard carefully. long long's guaranteed
maximum and minimum values are representable only if you use at least
64 bits.

There are, unfortunately, a _lot_ of things the standard says that it
doesn't really come out and say. Long long int is required to represent
the range from 2^63-1 to -2^63+1, inclusive. Unsigned long long int is
required to represent the range from 1 to 2^64-1.
 
M

Michael Mair

Jordan said:
http://home.tiscalinet.ch/t_wolf/tw/c/c9x_changes.html is probably
better for the purpose of the question. At a glance, though, the page
you linked is a good analysis of the most recent chapter in the
compatibility and lack thereof between C and C++, though.

Ah, will have a look at this page.
BTW: David Tribble's page was a good first C99 introduction
for me :)
Where does it say that? I'm confused by "rank", does that mean they
can't all be the same width?

No. This is the conversion rank. Whenever you have the same signedness
and different conversion rank, the numbers representable by the
integer type with lower rank also are within the range that can be
represented by the integer type with higer rank.
Have a look at 6.2.5 and 6.3.1.1 for a start.

There are, unfortunately, a _lot_ of things the standard says that it
doesn't really come out and say. Long long int is required to represent
the range from 2^63-1 to -2^63+1, inclusive. Unsigned long long int is
required to represent the range from 1 to 2^64-1.
(ITYM 0 to 2^64-1)

This is true -- I regularly prove my misreading of the standard
round here... However, as rank is defined in a relatively clear
way (by the standard's standards ;-)), it should be clear that
the range of long long is not restricted by the cited part.


Cheers
Michael
 
M

mechanicfem

Jordan said:
http://home.tiscalinet.ch/t_wolf/tw/c/c9x_changes.html is probably
better for the purpose of the question. At a glance, though, the page
you linked is a good analysis of the most recent chapter in the
compatibility and lack thereof between C and C++, though.


Where does it say that? I'm confused by "rank", does that mean they
can't all be the same width?


There are, unfortunately, a _lot_ of things the standard says that it
doesn't really come out and say. Long long int is required to represent
the range from 2^63-1 to -2^63+1, inclusive. Unsigned long long int is
required to represent the range from 1 to 2^64-1.

Thanks for the info and the links.

x

Jo
 

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
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top