Suppose I want to write a C program (C99 or C2011) that I want to fully port and not bind to a specific architecture.
It seems like I would like to make a clean break with the old integer types ( int , long , short ) and friends and use only int8_t , uint8_t , int32_t and (possibly using the least and fast versions).
What is the main return type? Or should we stream with int ? Is a standard int value required?
GCC-4.2 allows me to write
#include <stdint.h> #include <stdio.h> int32_t main() { printf("Hello\n"); return 0; }
but i can't use uint32_t or even int8_t because then i get
hello.c:3: warning: return type of 'main' is not 'int'
This is due to typedef, no doubt. This seems to be one case where we are stuck with unspecified size types, since it is not really portable unless we leave the return type to the target architecture. Is this interpretation correct? It seems strange to have “only one” simple old int in the code base, but I'm happy to be pragmatic.
source share