Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it posible to check if a struct was defined before (in a header file) during preprocessor?

Tags:

c

I want to check if a certain structure was defined in a header file I included and define it if it is not. The header might, or might not be included in the source file and that is (obviously) known at compile time.

Essentially I want something similar to the ifndef guards used in header files and I know that I could use a check if the header file where the struct is defined is included by checking it's guard, but I am wandering if I could check for the struct itself.

like image 826
Dimitar Slavchev Avatar asked Aug 28 '12 09:08

Dimitar Slavchev


1 Answers

No. The preprocessor doesn't parse the C language itself, it knows nothing of the declared types.

like image 106
unwind Avatar answered Oct 27 '22 00:10

unwind