If a compiler has a certain type (ex. ptrdiff_t) as an embedded type, I don't want to typedef it again. I know that below code does not work properly that I expected.
#ifndef ptrdiff_t
typedef long int ptrdiff_t;
#endif
How can I check a certain type is already defined in the C compiler?
There's no way to do that in general. In some cases there may be a macro that is defined at the same time as the type that you can use.
In your particular example, you can #include <stddef.h>
, which should always define ptrdiff_t.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With