473,544 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sizes of Integer Types

Hi,

I have a 32-bit machine... Is there anyway I can get gcc to use the
following integer sizes?
char: 8 bits
short: 16 bits
int: 32 bits
long: 64 bits
long long: 128 bits

Thanks!

Bob.

Sep 5 '07 #1
159 6132
Bob Timpkinson wrote:
Hi,

I have a 32-bit machine... Is there anyway I can get gcc to use the
following integer sizes?
char: 8 bits
short: 16 bits
int: 32 bits
long: 64 bits
long long: 128 bits

Thanks!

Bob.
No way unless:
1) You download the source code of gcc
2) Change quite a few things inside

You would have to work for approx 6 months to 2 years depending
on your luck and knowledge about compilers

Just as a gcc user I see no way to do that.

But why you want that in the first place?
Sep 5 '07 #2
Bob Timpkinson <bo*@nospam.com writes:
I have a 32-bit machine... Is there anyway I can get gcc to use the
following integer sizes?
char: 8 bits
short: 16 bits
int: 32 bits
long: 64 bits
long long: 128 bits
We don't know. Try asking in gnu.gcc.help.

--
Keith Thompson (The_Other_Keit h) 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"
Sep 5 '07 #3
On Wed, 5 Sep 2007 09:18:00 +0200 (CEST), in comp.lang.c , Bob
Timpkinson <bo*@nospam.com wrote:
>Hi,

I have a 32-bit machine... Is there anyway I can get gcc to use the
following integer sizes?
char: 8 bits
short: 16 bits
int: 32 bits
long: 64 bits
long long: 128 bits
Why would you want to?
Compilers are built to match the hardware / software environment
they're targetting.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Sep 5 '07 #4
I don't believe that's true - surely any C compiler worth its salt will
allow you to set this sort of option?

It seems logical to me to give every integer size its own type, and then
you can program with confidence knowing how big each variable will be.

Bob.

On 5 Sep 2007 at 7:22, jacob navia wrote:
Bob Timpkinson wrote:
>Hi,

I have a 32-bit machine... Is there anyway I can get gcc to use the
following integer sizes?
char: 8 bits
short: 16 bits
int: 32 bits
long: 64 bits
long long: 128 bits

Thanks!

Bob.

No way unless:
1) You download the source code of gcc
2) Change quite a few things inside

You would have to work for approx 6 months to 2 years depending
on your luck and knowledge about compilers

Just as a gcc user I see no way to do that.

But why you want that in the first place?
Sep 5 '07 #5
Bob Timpkinson wrote:
I don't believe that's true - surely any C compiler worth its salt will
allow you to set this sort of option?

It seems logical to me to give every integer size its own type, and then
you can program with confidence knowing how big each variable will be.

Bob.
I repeat:
There is NO C compiler that allows you to change the sizes of the
basic types. Period.

Please show me one C compiler that does that.

jacob
Sep 5 '07 #6
Bob Timpkinson <bo*@nospam.com writes:
I have a 32-bit machine... Is there anyway I can get gcc to use the
following integer sizes?
char: 8 bits
short: 16 bits
int: 32 bits
long: 64 bits
long long: 128 bits
gnu.gcc.help is a better place for this kind of question.
Followups set.

<OFF-TOPIC>
I don't think so. In particular, I don't think GCC has support
for quad-word 128-bit arithmetic, except for use with
processor-specific built-in functions for e.g. SSE support.
</OFF-TOPIC>
--
"I hope, some day, to learn to read.
It seems to be even harder than writing."
--Richard Heathfield
Sep 5 '07 #7
jacob navia wrote, On 05/09/07 20:17:
Bob Timpkinson wrote:
>I don't believe that's true - surely any C compiler worth its salt will
allow you to set this sort of option?

It seems logical to me to give every integer size its own type, and then
you can program with confidence knowing how big each variable will be.

I repeat:
There is NO C compiler that allows you to change the sizes of the
basic types. Period.

Please show me one C compiler that does that.
gcc 3.3.3
-m96bit-long-double/-m128-bit-long-double
-m32/-m64

Or then there are some of the old 80x86 compilers that allowed you to
select one of a number of sies for pointers.

Of course, you cannot select any values you want, and you can't select
what the OP wanted, but you *can* change them between allowed values.
--
Flash Gordon
Sep 5 '07 #8
Flash Gordon wrote:
jacob navia wrote, On 05/09/07 20:17:
>Bob Timpkinson wrote:
>>I don't believe that's true - surely any C compiler worth its salt will
allow you to set this sort of option?

It seems logical to me to give every integer size its own type, and then
you can program with confidence knowing how big each variable will be.

I repeat:
There is NO C compiler that allows you to change the sizes of the
basic types. Period.

Please show me one C compiler that does that.

gcc 3.3.3
-m96bit-long-double/-m128-bit-long-double
-m32/-m64

Or then there are some of the old 80x86 compilers that allowed you to
select one of a number of sies for pointers.

Of course, you cannot select any values you want, and you can't select
what the OP wanted, but you *can* change them between allowed values.
This is a completely different thing and you know it.
Sep 5 '07 #9
jacob navia <ja***@jacob.re mcomp.frwrites:
Bob Timpkinson wrote:
>I don't believe that's true - surely any C compiler worth its salt will
allow you to set this sort of option?
It seems logical to me to give every integer size its own type, and
then
you can program with confidence knowing how big each variable will be.

I repeat:
There is NO C compiler that allows you to change the sizes of the
basic types. Period.

Please show me one C compiler that does that.
You really should stop and think for a moment before making sweeping
statements like that.

Here's the source file "c.c" that I use for all three tests:
#include <stdio.h>
int main(void)
{
printf("sizeof( long) = %d\n", (int)sizeof(lon g));
return 0;
}

On SPARC Solaris 9:
=============== =============== ==
% cc -V
cc: Sun C 5.5 Patch 112760-18 2005/06/14
usage: cc [ options] files. Use 'cc -flags' for details
% cc c.c -o c && ./c
sizeof(long) = 4
% cc -xtarget=ultra -xarch=v9 c.c -o c && ./c
sizeof(long) = 8
=============== =============== ==

On Fedora x86-64:
=============== =============== ==
% gcc --version | head -1
gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13)
% gcc -m32 c.c -o c && ./c
sizeof(long) = 4
% gcc -m64 c.c -o c && ./c
sizeof(long) = 8
=============== =============== ==

On AIX PowerPC:
=============== =============== ==
% xlc -qversion
IBM XL C/C++ Enterprise Edition V8.0 for AIX
Version: 08.00.0000.0011
% xlc -q32 c.c -o c && ./c
sizeof(long) = 4
% xlc -q64 c.c -o c && ./c
sizeof(long) = 8
=============== =============== ==

I don't know of any compilers that allow you to specify the sizes of
*all* the predefined integer types.

--
Keith Thompson (The_Other_Keit h) 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"
Sep 5 '07 #10

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

Similar topics

8
5910
by: Ken | last post by:
Hi. Does the Java spec mandate set sizes for primitive types (e.g., int, float, char, etc.)? I know the ANSI C++ standard does not do this, which makes these sizes compiler dependent. So I guess I'm trying to figure out if in Java these sizes are compiler or JVM dependent. Thanks! Ken
14
13009
by: David Fisher | last post by:
The most common sizes of integer types seem to be: 8 bits - signed char 16 bits - short 16 or 32 bits - int 32 or 64 bits - long Question #1: Does anyone know how common sizes other than these are ? I know that the
25
2044
by: gamehack | last post by:
Hi all, I'm writing an application which will be opening binary files with definite sizes for integers(2 byte integers and 4 byte longs). Is there a portable way in being sure that each integer will be exactly 2 bytes? Should I have a platform dependent header file which checks for CHAR_BIT and sizeof(int) etc and have a few typedefs like...
14
2326
by: Michael Brennan | last post by:
Hi, I wonder if there is any good reason to let different systems have different sizes of short, int and long? I think that makes it harder to plan which type to use for your program. For example, if I want to make a portable program which uses, say, an int type for a counter, and one system uses 16-bit for ints, and some other system uses...
13
2716
by: Ioannis Vranos | last post by:
Is there any mentioning in the standard of the number of bits of the various built in types, apart from char/signed char/unsigned char types? Or only about the minimum value ranges of them?
0
7437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7373
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7625
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7717
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5928
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5306
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3427
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
677
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.