If you really, absolutely want to ban native types, but allow typedefs , I think you can always do something like:
#include <stdint.h> #define int please_use_stdint_typedefs_rather_than_native_types int main() { int32_t good; // Good typedef. int evil; // Evil native type. }
$ gcc -c int_forbidden.c int_forbidden.c: In function 'main': int_forbidden.c:8: error: 'please_use_stdint_typedefs_rather_than_native_types' undeclared (first use in this function) int_forbidden.c:8: error: (Each undeclared identifier is reported only once int_forbidden.c:8: error: for each function it appears in.) int_forbidden.c:8: error: expected ';' before 'evil'
However, I do not think that explicitly prohibiting native types is a good idea in the general case.
Frédéric hamidi
source share