Connecting Tech Pros Worldwide Forums | Help | Site Map

long long extended type in c89?

j
Guest
 
Posts: n/a
#1: Nov 13 '05
Sadly, I don't have a copy of the c89 standard, just a copy of the c99
standard. I was curious if in c89, the type ``long long'' is indeed
considered an extended type that may or may not be implemented by the
implementation? And if it states whether or not the size of ``long
long'' is equal to the size of ``long'' or can be greater than the
size there-of?

Kevin Easton
Guest
 
Posts: n/a
#2: Nov 13 '05

re: long long extended type in c89?


Jack Klein <jackklein@spamcop.net> wrote:[color=blue]
> On 23 Aug 2003 15:54:02 -0700, jake30@bellsouth.net (j) wrote in
> comp.lang.c:
>[color=green]
>> Sadly, I don't have a copy of the c89 standard, just a copy of the c99
>> standard. I was curious if in c89, the type ``long long'' is indeed
>> considered an extended type that may or may not be implemented by the
>> implementation? And if it states whether or not the size of ``long
>> long'' is equal to the size of ``long'' or can be greater than the
>> size there-of?[/color]
>
> The original C standard, as well as the C99 standard, allow a
> conforming implementation to provide extensions as long as they do not
> impact any strictly conforming program.
>
> Using the keyword long twice within one declaration is an error in a
> pre-C99 keyword, so an implementation is free to provide a type named
> "long long" as an extension. Since it is completely an extension, it
> can be anything at all that the implementation wants it to be.[/color]

I believe, as a syntax error, that it must be diagnosed.

- Kevin.

j
Guest
 
Posts: n/a
#3: Nov 13 '05

re: long long extended type in c89?


Jack Klein <jackklein@spamcop.net> wrote in message news:<frqgkv4a85d109lku3nk8igm47jd0q4eup@4ax.com>. ..[color=blue]
> On 23 Aug 2003 15:54:02 -0700, jake30@bellsouth.net (j) wrote in
> comp.lang.c:
>[color=green]
> > Sadly, I don't have a copy of the c89 standard, just a copy of the c99
> > standard. I was curious if in c89, the type ``long long'' is indeed
> > considered an extended type that may or may not be implemented by the
> > implementation? And if it states whether or not the size of ``long
> > long'' is equal to the size of ``long'' or can be greater than the
> > size there-of?[/color]
>
> The original C standard, as well as the C99 standard, allow a
> conforming implementation to provide extensions as long as they do not
> impact any strictly conforming program.
>
> Using the keyword long twice within one declaration is an error in a
> pre-C99 keyword, so an implementation is free to provide a type named
> "long long" as an extension. Since it is completely an extension, it
> can be anything at all that the implementation wants it to be.
>
> Prior to C99, there was a DR that stated that no standard integer type
> could be "longer" than long, i.e., size_t, ptrdiff_t, and so on. But
> a "long long" type in a pre-C99 compiler would be an extension, not a
> standard type, and the only limitation placed on extensions is the one
> above.[/color]


That is what I was looking for. Thanks Jack. :)
Jack Klein
Guest
 
Posts: n/a
#4: Nov 13 '05

re: long long extended type in c89?


On Sun, 24 Aug 2003 11:34:25 GMT, Kevin Easton
<kevin@-nospam-pcug.org.au> wrote in comp.lang.c:
[color=blue]
> Jack Klein <jackklein@spamcop.net> wrote:[color=green]
> > On 23 Aug 2003 15:54:02 -0700, jake30@bellsouth.net (j) wrote in
> > comp.lang.c:
> >[color=darkred]
> >> Sadly, I don't have a copy of the c89 standard, just a copy of the c99
> >> standard. I was curious if in c89, the type ``long long'' is indeed
> >> considered an extended type that may or may not be implemented by the
> >> implementation? And if it states whether or not the size of ``long
> >> long'' is equal to the size of ``long'' or can be greater than the
> >> size there-of?[/color]
> >
> > The original C standard, as well as the C99 standard, allow a
> > conforming implementation to provide extensions as long as they do not
> > impact any strictly conforming program.
> >
> > Using the keyword long twice within one declaration is an error in a
> > pre-C99 keyword, so an implementation is free to provide a type named
> > "long long" as an extension. Since it is completely an extension, it
> > can be anything at all that the implementation wants it to be.[/color]
>
> I believe, as a syntax error, that it must be diagnosed.
>
> - Kevin.[/color]

Look at paragraphs 4 and 5 of Section 4 (C99):

"A strictly conforming program shall use only those features of the
language and library specified in this International Standard."

---and---

"A conforming implementation may have extensions (including additional
library functions), provided they do not alter the behavior of any
strictly conforming program."

I would say that a program containing a syntax error is *NOT* a
strictly conforming program (first quotation). Therefore a conforming
implementation is free to make an extension out of something that
would otherwise be a syntax error.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Kevin Easton
Guest
 
Posts: n/a
#5: Nov 13 '05

re: long long extended type in c89?


Jack Klein <jackklein@spamcop.net> wrote:[color=blue]
> On Sun, 24 Aug 2003 11:34:25 GMT, Kevin Easton
> <kevin@-nospam-pcug.org.au> wrote in comp.lang.c:
>[color=green]
>> Jack Klein <jackklein@spamcop.net> wrote:[color=darkred]
>> > On 23 Aug 2003 15:54:02 -0700, jake30@bellsouth.net (j) wrote in
>> > comp.lang.c:
>> >
>> >> Sadly, I don't have a copy of the c89 standard, just a copy of the c99
>> >> standard. I was curious if in c89, the type ``long long'' is indeed
>> >> considered an extended type that may or may not be implemented by the
>> >> implementation? And if it states whether or not the size of ``long
>> >> long'' is equal to the size of ``long'' or can be greater than the
>> >> size there-of?
>> >
>> > The original C standard, as well as the C99 standard, allow a
>> > conforming implementation to provide extensions as long as they do not
>> > impact any strictly conforming program.
>> >
>> > Using the keyword long twice within one declaration is an error in a
>> > pre-C99 keyword, so an implementation is free to provide a type named
>> > "long long" as an extension. Since it is completely an extension, it
>> > can be anything at all that the implementation wants it to be.[/color]
>>
>> I believe, as a syntax error, that it must be diagnosed.
>>
>> - Kevin.[/color]
>
> Look at paragraphs 4 and 5 of Section 4 (C99):
>
> "A strictly conforming program shall use only those features of the
> language and library specified in this International Standard."
>
> ---and---
>
> "A conforming implementation may have extensions (including additional
> library functions), provided they do not alter the behavior of any
> strictly conforming program."
>
> I would say that a program containing a syntax error is *NOT* a
> strictly conforming program (first quotation). Therefore a conforming
> implementation is free to make an extension out of something that
> would otherwise be a syntax error.[/color]

I point you to Section 5 (I'm quoting here from N869):

5.1.1.3 Diagnostics
1 A conforming implementation shall produce at least one diagnostic
message (identified in an implementation-defined manner) if a
preprocessing translation unit or translation unit contains a violation
of any syntax rule or constraint, even if the behavior is also
explicitly specified as undefined or implementation-defined. Diagnostic
messages need not be produced in other circumstances.

(So an implementation can indeed provide a long long type, but it has to
say something like "Warning: You used the long long type!").

- Kevin.
Closed Thread