Is there a way to #define something as a #warning?
I tried using the following code, but it gives me an error:
'warning' undeclared (first use this function)
#define test(); #warning <windows.h> needs to be included for this function!
#endif
int main(void)
{
test();
return0;
}
If it's not possible to do this way, is there another way to do it, which will give a warning instead of the function, in case the function cannot be used?
Last edited by unbeatable0; Oct 8th, 2008 at 4:46 am.
> #define test(); #warning <windows.h> needs to be included for this function!
But if you don't have windows.h, then the code would have failed to compile before this point anyway.
fprintf(stderr, "_WIN32 not set, compilation should have failed!\n");
exit(0);
return0;
}
#endif
Or if you're trying to spot obsolete functionality, and you're using gcc, then perhaps this (this is the 2nd obscure snippet from the gcc manual today )
Quote originally posted by gcc manual ...
deprecated
The deprecated attribute results in a warning if the variable is used anywhere
in the source file. This is useful when identifying variables that are expected
to be removed in a future version of a program. The warning also includes the
location of the declaration of the deprecated variable, to enable users to easily
find further information about why the variable is deprecated, or what they
should do instead. Note that the warning only occurs for uses:
extern int old_var __attribute__ ((deprecated));
extern int old_var;
int new_fn () { return old_var; }
results in a warning on line 3 but not line 2.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.