How do data types work after const in C?

1

I'm reading some code and I came across the following code

#define foo unsigned int
#define i typedef

I know how this unsigned and signed, typedef etc works, but I can not figure out how this works on the constant.

    
asked by anonymous 19.09.2016 / 21:07

1 answer

4

This example shown in the question is not useful at all, except to demonstrate the #define directive.

The result of this is as follows:

#define foo unsigned int
#define i typedef

// bla bla bla

foo x;     // literalmente: "unsigned int x;"
i int y;   // literalmente: "typedef int y;"
y z;       // literalmente: "int z;"

As I said above, this example is not useful at all, just to demonstrate the #define directive. Obviously, the #define directive is very useful and appears a lot in the C language libraries themselves.

    
19.09.2016 / 21:16