Re: data types



Roberto Waltman wrote:
koolj96825@xxxxxxxxx wrote:

... an int could be 32-bit for PCs.
...but the manual for the compiler I am using says int is 16-bit.

Anyway, now that I need to go back over and look closely at my
code, my question is: is there a way to declare a variable say a
16 bit unsigned integer in C? Or is declaring it "short" the only
specifier that may work?

For non-C99 compilers, the common, non-portable way of doing it is:

typedef [whatever type is 16 bits in your platform] int16;
typedef [whatever type is 32 bits in your platform] int32;

and so on. Then use int16/32/etc. instead of plain int in your code.

Better to look at the range of values required and set your
fundamental types accordingly. Just don't bother with such
constraints as the above, as there may be no such type extant.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


.



Relevant Pages

  • Re: integer size and portability-a wishful controversy
    ... >> BTW, there is no point in using the old Turbo C compiler, unless ... I do NOT consider programs relying on int having at least 32 bits as ... use the PC as an almost freestanding platform for developing/testing ... device drivers for various pieces of PC hardware. ...
    (comp.lang.c)
  • Re: Tcl_CreateCommand in 8.4.4
    ... Tcl_CmdProc typedef is now a bit different. ... typedef int _ANSI_ARGS_((ClientData clientData, ... This way the compiler complains SomeCmd sig ...
    (comp.lang.tcl)
  • Re: c dll to c#
    ... just name me a C compiler that targets the Microsoft Windows ... platform who has a 64 bit "built-in" long type. ... mapping for an int and a long looks like: ...
    (microsoft.public.dotnet.languages.csharp)
  • printf anomaly
    ... My understanding is that the 1000 will default to int ... Then it will be promoted to unsigned long (since on our platform long ... and printf is a variadic ... I must be missing something or the compiler is broken? ...
    (comp.lang.c)
  • Re: Fooling C Compiler
    ... I tried using typedef. ... Is there a possibility to fool your doctor ... I assume "fooling the compiler" was meant to be ...
    (comp.lang.c)