Why doesn’t the following code work as expected?
void foobar(int);
#ifndef foobar
printf("foobar exists");
#endif
It always prints the message; it obviously cannot detect the existence of a function as an entity. (Is it an over-loading issue?)
Why can’t #ifdef
(or its variants) detect function declarations? Declarations should be available at pre-processing, so it should work, shouldn’t it? If not, is there an alternative or work-around?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…