public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: 16-bit int
@ 2012-08-10  7:16 Göran Steen
  2012-08-10  8:20 ` David Brown
  0 siblings, 1 reply; 24+ messages in thread
From: Göran Steen @ 2012-08-10  7:16 UTC (permalink / raw)
  To: gcc-help

Thank you for your response.

I want to make sure that my code snippets, if they are compiled and run on a machine with 16-bit int, still works. I don't have access to such a machine, so I want to compile and run them with 16-bit int on my machine that defaults to 32-bit int. Especially the intermediate results' size are interesting. What happens if they are truncated to 16-bit?

There will not be any problem with library compatibility.

BR /göran

-----Original Message-----
From: David Brown [mailto:david@westcontrol.com]
Sent: den 9 augusti 2012 15:37
To: Göran Steen
Cc: gcc-help@gcc.gnu.org
Subject: Re: 16-bit int

On 09/08/2012 13:26, Göran Steen wrote:
> Hi!
>
> I use gcc version 4.3.4, where int is 32-bit variables. Is it possible 
> to setup compiler to compile int as 16-bit variables?
>
> With best regards / Med vänlig hälsning / Mit freundlichen Grüßen / 
> Saudações
>
> Göran Steen


The size of an int depends on the target - gcc supports dozens of targets.  Most have 32-bit ints, but some have 16-bit ints and at least one has a compile-time option to support 8-bit ints (though that goes against C standards, and is deprecated on current builds).  There are probably also targets with 64-bit ints.

So step one in asking for help here is to tell us your target.

Step two is to tell us what you are hoping to achieve.  Almost certainly, there is no way to change the int size - and even if there happens to be a command-line switch for the given target, it is probably not a good idea (you'll get in a horrible mess with library compatibility, for example).  And even if it is possible, it is highly unlikely to be advantageous.  Tell us what you really want to achieve here, and people can give you advice towards that.

mvh.,

David

^ permalink raw reply	[flat|nested] 24+ messages in thread
* 16-bit int
@ 2012-08-09 11:26 Göran Steen
  2012-08-09 13:45 ` David Brown
  2012-08-09 17:14 ` Paulo J. Matos
  0 siblings, 2 replies; 24+ messages in thread
From: Göran Steen @ 2012-08-09 11:26 UTC (permalink / raw)
  To: gcc-help

Hi!

I use gcc version 4.3.4, where int is 32-bit variables. Is it possible to setup compiler to compile int as 16-bit variables?

With best regards / Med vänlig hälsning / Mit freundlichen Grüßen / Saudações

Göran Steen
Senior Software Developer
EIS Mälardalen
 
EIS by Semcon AB
Patentgatan 8
112 67 STOCKHOLM
Sweden
 
Phone 08-56290697
Mobile 073-6840004
E-mail goran.steen@eis.semcon.com
 
www.semcon.com
www.facebook.com/semcon

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-08-13  9:34 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-10  7:16 16-bit int Göran Steen
2012-08-10  8:20 ` David Brown
2012-08-10  8:35   ` David Brown
2012-08-10  8:53   ` Göran Steen
2012-08-10  9:05     ` David Brown
2012-08-10  9:19       ` Göran Steen
2012-08-10  9:21         ` David Brown
2012-08-11 15:32         ` Vincent Lefevre
2012-08-11 16:28           ` Ian Lance Taylor
2012-08-11 19:36             ` Tim Prince
2012-08-13 14:42           ` David Brown
2012-08-10 18:01     ` Jonathan Wakely
2012-08-11 10:47   ` Vincent Lefevre
  -- strict thread matches above, loose matches on Subject: below --
2012-08-09 11:26 Göran Steen
2012-08-09 13:45 ` David Brown
2012-08-09 18:52   ` Vincent Lefevre
2012-08-09 19:59     ` David Brown
2012-08-09 22:39       ` Vincent Lefevre
2012-08-09 22:52         ` Ian Lance Taylor
2012-08-10  6:53           ` Jose-Marcio Martins da Cruz
2012-08-11 10:33           ` Vincent Lefevre
2012-08-10  6:48   ` Georg-Johann Lay
2012-08-10  8:16     ` David Brown
2012-08-09 17:14 ` Paulo J. Matos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).