473,480 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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

Jun 22 '07 #1
21 2775
On Jun 22, 2:55 pm, Charles Sullivan <cwsul...@triad.rr.comwrote:
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.
The long long type was officially introduced with the 1999 Standard,
hence no mention of it in K&R2 which was published 10 years earlier.
A number of compilers recognized and supported the type well before
the new Standard was published, the "long long" name was selected
based on consideration of this fact. While most compilers don't
implement all of C99, a good many of those released in the last 10
years do support long long. Some compilers may require an option to
be set to enable support for long long so keep this in mind. As for
whether it is widely enough supported for your needs, it would be a
good idea to review the compilers you currently support and see if any
of them don't support this type and go from there.

Robert Gamble

Jun 22 '07 #2
Charles Sullivan <cw******@triad.rr.comwrites:
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.
The types "long long" and "unsigned long long" were introduced in the
ISO C standard of 1999. That standard is not yet widely implemented,
though pieces of it are.

Many, perhaps most, compilers support long long as an extension, but a
compiler invoked in strict C90 mode will reject long long, even if it
would accept it in a more relaxed mode.

Why do you need "long long"? I suspect what you really need is a
64-bit integer type; long long is guaranteed (in C99) to be at least
64 bits, but it's entirely possible for long to be 64 bits in either
C90 or C99.

I think that some compilers may provide 64-bit integer types, but
without using the name "long long" (Microsoft?).

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>).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <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"
Jun 22 '07 #3
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. They
may be available on other systems as extensions, but will not be
portable.

--
<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

Jun 22 '07 #4
CBFalconer <cb********@yahoo.comwrites:
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).

If you do have a C99 compiler, long long will work.

It does not follow from this that if you don't have a C99 compiler,
long long won't work.
They may be available on other systems as extensions, but will not
be portable.
Exactly. And in fact, "long long" is one of the most common
extensions; I know of very few current C compilers that don't support
it. It's not 100% portable, though; it's up to the OP to decide
whether it's portable *enough*.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <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"
Jun 22 '07 #5
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?

--
Ian Collins.
Jun 22 '07 #6
On Jun 22, 11:55 am, Charles Sullivan <cwsul...@triad.rr.comwrote:
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.
Older Microsoft compilers and the OpenVMS C and C++ compilers use:
__int64 and unsigned __int64

The current Microsoft compiler and recent GCC versions accept long
long just fine.

However, you can still run into speedbumps today. Some older, still
running platforms do not have long long (e.g. OpenVMS VAX).

Jun 23 '07 #7
Ian Collins <ia******@hotmail.comwrites:
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?
Probably, depending on what you need them for.

If you need types that are exactly 64 bits wide, then yes, it makes
sense to use int64_t and uint64_t (from <inttypes.hif it exists, or
defining them yourself if they don't).

I think you're assuming that when the OP says "I need long long", he
really means "I need a type that's exactly 64 bits wide". That
assumption is likely to be correct (I've never heard of a C compiler
where long long is anything other than exactly 64 bits) -- but that's
not what "long long" means.

Actually, I think the OP is dealing with some existing code that
depends on long long. The appropriate course of action, particularly
for implementations that don't support long long, probably depends on
just how the code uses it.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <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"
Jun 23 '07 #8
Keith Thompson wrote:
CBFalconer <cb********@yahoo.comwrites:
>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.

--
<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

Jun 23 '07 #9
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.

--
<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

Jun 23 '07 #10
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.
Jun 23 '07 #11
CBFalconer wrote:
Keith Thompson wrote:
>CBFalconer <cb********@yahoo.comwrites:
>>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.
Jun 23 '07 #12
CBFalconer <cb********@yahoo.comwrites:
Keith Thompson wrote:
>CBFalconer <cb********@yahoo.comwrites:
>>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) ks***@mib.org <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"
Jun 23 '07 #13
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

Jun 23 '07 #14
CBFalconer <cb********@yahoo.comwrites:
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) ks***@mib.org <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"
Jun 23 '07 #15
Keith Thompson wrote:
CBFalconer <cb********@yahoo.comwrites:
>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

Jun 24 '07 #16
CBFalconer <cb********@yahoo.comwrites:
Keith Thompson wrote:
>CBFalconer <cb********@yahoo.comwrites:
>>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) ks***@mib.org <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"
Jun 24 '07 #17

"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
CBFalconer <cb********@yahoo.comwrites:
>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>
Jun 24 '07 #18
"Barry" <ba****@nullhighstream.netwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
[...]
>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) ks***@mib.org <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"
Jun 24 '07 #19
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
Jun 24 '07 #20
On Sun, 24 Jun 2007 10:22:43 -0400, Charles Sullivan
<cw******@triad.rr.comwrote:

snip
>
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.
It might be even simpler to switch once to an array of unsigned char
and never have to worry about type sizes again.
Remove del for email
Jun 25 '07 #21
On Sun, 24 Jun 2007 17:17:56 -0700, Barry Schwarz wrote:
On Sun, 24 Jun 2007 10:22:43 -0400, Charles Sullivan
<cw******@triad.rr.comwrote:

snip
>>
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.

It might be even simpler to switch once to an array of unsigned char
and never have to worry about type sizes again.
Thanks for the suggestion. However just the thought of all the
recoding that would require makes my brain hurt :-)

Regards,
Charles Sullivan
Jun 25 '07 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
11896
by: Alex Wisnoski | last post by:
I have an A97 application that I am modifying. I have created an unbound form, "zfrmTestEnterPlacements", with a subform, "zsfrmSelectPlacement". The intent is to use a combo box on the primary...
8
4999
by: Groups User | last post by:
C allows type casting in which a variable is converted from one type to another. Does C (whatever standard) allow the type of a variable to change, within a statement, avoiding the conversion?...
2
1804
by: Avi Laviad | last post by:
hi, sorry for the dumb question but how do i code a bit variable in c? i mean - shoudlnt the synax need to be: bit j; j = 1; correct me if im wrong (and i suppose i am). Avi.
1
3252
by: Shawn | last post by:
As if it won't be clear enough from my code, I'm pretty new to C programming. This code is being compiled with an ANSI-C compatible compiler for a microcontroller. That part, I believe, will be...
20
224937
by: Manuel | last post by:
hi, I have a problem, a stupid problem. I can't declare a variable of type byte. The g++ said that i have syntactic error in this line. The code is this: byte * variable; well, i think...
1
2763
by: ares.lagae | last post by:
- I have a typelist and I want to declare a member variable for each of the types. How can I do that? E.g. I have the typelist "typedef boost::mpl::vector<int, float> types;" and I want to declare...
38
2182
by: junky_fellow | last post by:
Guys, I was just looking at some code where to initialize an integer with all F's following statement is used; unsigned int i = -1; I want to know if this is the right way of doing the...
22
1475
by: Tristin.Colby | last post by:
Can someone tell me why giv_len isn't being seen in this statement below "printf("Record %d wrong length:%d Should be %d \n",record,cur_len,giv_len)" =cut #include <stdio.h> #include...
28
7092
by: Trups | last post by:
HI, I want to dynamically allocate array variable of type LPWSTR. Code looks like this... main() { LPWSTR *wstr; int count = Foo (wstr); for (int i = 0; i < count; i++)
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3013
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.