"Portability" contructs like UINT32 etc.



"Sunil" <sunil.goutham@xxxxxxxxx> writes:

> Hi all,
>
> I am using gcc compiler in linux.I compiled a small program
> int main()
> {
> printf("char : %d\n",sizeof(char));
> printf("unsigned char : %d\n",sizeof(unsigned char));
> printf("short : %d\n",sizeof(short));

<SNIP>

This brings to mind something that I have wondered about.

I often see advice elsewhere, and in other peoples programs,
suggesting hiding all C "fundamental" types behind typedefs such as

typedef char CHAR;
typedef int INT32;
typedef unsigned int UINT32;
typedef char* PCHAR;

The theory is that application code which always uses these typedefs
will be more likely to run on multiple systems (provided the typedefs
are changed of course).

I used to do this. Then I found out that C99 defined things like
"uint32_t", so I started using these versions instead. But after
following this group for a while I now find even these ugly and don't
use them unless unavoidable.

What do people here think is best?

--

John Devereux
.



Relevant Pages

  • Re: "Portability" contructs like UINT32 etc.
    ... > typedef char CHAR; ... > typedef int INT32; ... > typedef char* PCHAR; ... Both processors had hardware alignment requirements. ...
    (comp.lang.c)
  • Bypassing Personal Firewalls
    ... typedef SOCKET (int, int, int); ... typedef int (__stdcall *func_connect)(SOCKET, const struct sockaddr ... typedef HANDLE (LPCTSTR, DWORD, DWORD, ...
    (Bugtraq)
  • Bypassing Personal Firewalls
    ... typedef SOCKET (int, int, int); ... typedef int (__stdcall *func_connect)(SOCKET, const struct sockaddr ... typedef HANDLE (LPCTSTR, DWORD, DWORD, ...
    (Vuln-Dev)
  • Re: typedef with function pointers
    ... typedef has the same syntax as defining variables. ... The above defines an array called "arr" with five int elements. ... Each element is a pointer ... typedef char frpapfrc; ...
    (comp.lang.c)
  • Re: "Portability" contructs like UINT32 etc.
    ... >> I am using gcc compiler in linux.I compiled a small program ... > typedef char CHAR; ... > typedef int INT32; ... > typedef char* PCHAR; ...
    (comp.lang.c)