Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How widely supported is variable type 'long long int' ?

Reply
Thread Tools

How widely supported is variable type 'long long int' ?

 
 
Ian Collins
Guest
Posts: n/a
 
      06-23-2007
CBFalconer wrote:
> Ian Collins wrote:
>> Keith Thompson wrote:
>>> You might consider defining your own types, perhaps "long_long"
>>> and "unsigned_long_long", in an application-specific header;
>>> these would be typedefs for long long and unsigned long long
>>> where they're available, and for whatever other type is
>>> appropriate where they're not. You should be able to detect
>>> whether long long exists by checking "#ifdef LLONG_MAX" (after
>>> #include <limits.h>).

>> Wouldn't it be better just to use the standard int64_t and
>> uint64_t type names?

>
> They don't exist in C90. They may not exist in C99.
>

So, I was suggesting using the standard names.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      06-23-2007
CBFalconer wrote:
> Keith Thompson wrote:
>> CBFalconer <(E-Mail Removed)> writes:
>>> Charles Sullivan wrote:
>>> ... snip ...
>>>> It would be convenient (and for some things possibly necessary)
>>>> to use long long integer and/or unsigned long long integer
>>>> variables.
>>>>
>>>> How widely supported are these variable types? How long ago were
>>>> they introduced? I notice they are not mentioned in K&R #2.
>>> Long long was introduced with C99. If you don't have a C99
>>> compliant compiler (and you probably don't) they won't work.

>> Not true. I have a compiler that isn't C99 compliant, and it
>> supports "long long" just fine (if I don't invoke it in strict
>> C90 mode).

>
> You have a C90 compiler with enabled extensions.
>

Isn't that what Keith said ("if I don't invoke it in strict C90 mode")?

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      06-23-2007
CBFalconer <(E-Mail Removed)> writes:
> Keith Thompson wrote:
>> CBFalconer <(E-Mail Removed)> writes:
>>> Charles Sullivan wrote:
>>>>
>>> ... snip ...
>>>>
>>>> It would be convenient (and for some things possibly necessary)
>>>> to use long long integer and/or unsigned long long integer
>>>> variables.
>>>>
>>>> How widely supported are these variable types? How long ago were
>>>> they introduced? I notice they are not mentioned in K&R #2.
>>>
>>> Long long was introduced with C99. If you don't have a C99
>>> compliant compiler (and you probably don't) they won't work.

>>
>> Not true. I have a compiler that isn't C99 compliant, and it
>> supports "long long" just fine (if I don't invoke it in strict
>> C90 mode).

>
> You have a C90 compiler with enabled extensions.


Yes, of course -- which is entirely consistent with what I wrote, and
contradicts your earlier statement.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      06-23-2007
Ian Collins wrote:
> CBFalconer wrote:
>> Ian Collins wrote:
>>> Keith Thompson wrote:
>>>
>>>> You might consider defining your own types, perhaps "long_long"
>>>> and "unsigned_long_long", in an application-specific header;
>>>> these would be typedefs for long long and unsigned long long
>>>> where they're available, and for whatever other type is
>>>> appropriate where they're not. You should be able to detect
>>>> whether long long exists by checking "#ifdef LLONG_MAX" (after
>>>> #include <limits.h>).
>>>
>>> Wouldn't it be better just to use the standard int64_t and
>>> uint64_t type names?

>>
>> They don't exist in C90. They may not exist in C99.

>
> So, I was suggesting using the standard names.


Then you run into problems when they are defined in that system.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      06-23-2007
CBFalconer <(E-Mail Removed)> writes:
> Ian Collins wrote:
>> CBFalconer wrote:
>>> Ian Collins wrote:
>>>> Keith Thompson wrote:
>>>>> You might consider defining your own types, perhaps "long_long"
>>>>> and "unsigned_long_long", in an application-specific header;
>>>>> these would be typedefs for long long and unsigned long long
>>>>> where they're available, and for whatever other type is
>>>>> appropriate where they're not. You should be able to detect
>>>>> whether long long exists by checking "#ifdef LLONG_MAX" (after
>>>>> #include <limits.h>).
>>>>
>>>> Wouldn't it be better just to use the standard int64_t and
>>>> uint64_t type names?
>>>
>>> They don't exist in C90. They may not exist in C99.

>>
>> So, I was suggesting using the standard names.

>
> Then you run into problems when they are defined in that system.


So you define them yourself if and only if they're not already defined.

There's no good portable way in C to determine whether they're already
defined, but there are a number of ways to do so outside the language
(autoconf is one).

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      06-23-2007
Keith Thompson wrote:
> CBFalconer <(E-Mail Removed)> writes:
>> Ian Collins wrote:
>>> CBFalconer wrote:
>>>> Ian Collins wrote:
>>>>> Keith Thompson wrote:
>>>>>
>>>>>> You might consider defining your own types, perhaps "long_long"
>>>>>> and "unsigned_long_long", in an application-specific header;
>>>>>> these would be typedefs for long long and unsigned long long
>>>>>> where they're available, and for whatever other type is
>>>>>> appropriate where they're not. You should be able to detect
>>>>>> whether long long exists by checking "#ifdef LLONG_MAX" (after
>>>>>> #include <limits.h>).
>>>>>
>>>>> Wouldn't it be better just to use the standard int64_t and
>>>>> uint64_t type names?
>>>>
>>>> They don't exist in C90. They may not exist in C99.
>>>
>>> So, I was suggesting using the standard names.

>>
>> Then you run into problems when they are defined in that system.

>
> So you define them yourself if and only if they're not already
> defined. There's no good portable way in C to determine whether
> they're already defined, but there are a number of ways to do so
> outside the language (autoconf is one).


That's another matter entirely. What I suggest is trying VERY hard
to stick to the normal brew of short, int, long.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      06-24-2007
CBFalconer <(E-Mail Removed)> writes:
> Keith Thompson wrote:
>> CBFalconer <(E-Mail Removed)> writes:
>>> Ian Collins wrote:
>>>> CBFalconer wrote:
>>>>> Ian Collins wrote:
>>>>>> Keith Thompson wrote:
>>>>>>> You might consider defining your own types, perhaps "long_long"
>>>>>>> and "unsigned_long_long", in an application-specific header;
>>>>>>> these would be typedefs for long long and unsigned long long
>>>>>>> where they're available, and for whatever other type is
>>>>>>> appropriate where they're not. You should be able to detect
>>>>>>> whether long long exists by checking "#ifdef LLONG_MAX" (after
>>>>>>> #include <limits.h>).
>>>>>>
>>>>>> Wouldn't it be better just to use the standard int64_t and
>>>>>> uint64_t type names?
>>>>>
>>>>> They don't exist in C90. They may not exist in C99.
>>>>
>>>> So, I was suggesting using the standard names.
>>>
>>> Then you run into problems when they are defined in that system.

>>
>> So you define them yourself if and only if they're not already
>> defined. There's no good portable way in C to determine whether
>> they're already defined, but there are a number of ways to do so
>> outside the language (autoconf is one).

>
> That's another matter entirely. What I suggest is trying VERY hard
> to stick to the normal brew of short, int, long.


Sure, if you ignore the OP's explicit requirement it's really easy.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Barry
Guest
Posts: n/a
 
      06-24-2007

"Keith Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> CBFalconer <(E-Mail Removed)> writes:
>> Ian Collins wrote:
>>> CBFalconer wrote:
>>>> Ian Collins wrote:
>>>>> Keith Thompson wrote:
>>>>>> You might consider defining your own types, perhaps "long_long"
>>>>>> and "unsigned_long_long", in an application-specific header;
>>>>>> these would be typedefs for long long and unsigned long long
>>>>>> where they're available, and for whatever other type is
>>>>>> appropriate where they're not. You should be able to detect
>>>>>> whether long long exists by checking "#ifdef LLONG_MAX" (after
>>>>>> #include <limits.h>).
>>>>>
>>>>> Wouldn't it be better just to use the standard int64_t and
>>>>> uint64_t type names?
>>>>
>>>> They don't exist in C90. They may not exist in C99.
>>>
>>> So, I was suggesting using the standard names.

>>
>> Then you run into problems when they are defined in that system.

>
> So you define them yourself if and only if they're not already defined.
>
> There's no good portable way in C to determine whether they're already
> defined, but there are a number of ways to do so outside the language
> (autoconf is one).
>


<OT>
Autoconf is also not portable. Nor reliable.
</OT>


 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      06-24-2007
"Barry" <(E-Mail Removed)> writes:
> "Keith Thompson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...

[...]
>> So you define them yourself if and only if they're not already defined.
>>
>> There's no good portable way in C to determine whether they're already
>> defined, but there are a number of ways to do so outside the language
>> (autoconf is one).
>>

>
> <OT>
> Autoconf is also not portable. Nor reliable.
> </OT>


I didn't mean to imply otherwise.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Charles Sullivan
Guest
Posts: n/a
 
      06-24-2007
On Fri, 22 Jun 2007 14:55:14 -0400, Charles Sullivan wrote:

> I maintain/enhance some inherited FOSS software in C which has
> compiler options for quite a few different Unix-like operating
> systems, many of which I've never even heard of.
>
> It would be convenient (and for some things possibly necessary)
> to use long long integer and/or unsigned long long integer
> variables.
>
> How widely supported are these variable types? How long ago were
> they introduced? I notice they are not mentioned in K&R #2.
>
> Thanks for your help.
>
> Regards,
> Charles Sullivan


Many thanks to all who responded. Your comments have been
very useful.

For those who wondered why I needed long longs:
My app makes extensive use of unsigned long bitmaps and bitwise
logic. Enhancements to the app occasionally require defining new
bit positions and in some cases I'm getting close to running out.
It would be far simpler to switch to unsigned long long than to
reprogram to use multiple unsigned longs.

Thanks again.

Regards,
Charles Sullivan


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Having compilation error: no match for call to (const __gnu_cxx::hash<long long int>) (const long long int&) veryhotsausage C++ 1 07-04-2008 05:41 PM
Panorama photography / widely variable light - solution?? Destin_FL Digital Photography 9 06-20-2006 01:35 PM
How widely used is the IEEE numeric_std package? Chuck Roth VHDL 3 09-14-2005 10:25 PM
How widely used is Docbook? Bucco XML 2 08-10-2005 12:12 AM



Advertisments