![]() |
| ||
| Preprocessor #warning Command Question 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) This is the part of code where the error appears: #define something #warning This is not a standard function! Any help on this please? If it's not possible to perform, please tell :) Thanks in advance ;) |
| ||
| Re: Preprocessor #warning Command Question Never mind, I found the answer :P |
| ||
| Re: Preprocessor #warning Command Question Oh well... I was wrong. My method didn't work :( Please help me :) |
| ||
| Re: Preprocessor #warning Command Question I don't think the pre-processor is capable of expanding lines which are themselves pre-processing statements. In short, I don't think it's going to work. |
| ||
| Re: Preprocessor #warning Command Question Any help on this? If it helps, I want the macro to be a function. For example: #ifndef _WINDOWS_H 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? |
| ||
| Re: Preprocessor #warning Command Question Salem is right; there is no way to #define a macro that expands to a preprocessor directive. There is also the incidental concern that #warning is not a standard preprocessor directive. Any C++ compiler will generate an error on an attempt to call a function that has not previously been declared. I can't see the point of what you're trying to do. If <window.h> is not included #ifndef _WINDOWS_Hwill generate an error message that gives specific information on requirements. Of course, if you need to use the above (eg if you have a header that relies on <windows.h>) it would be easier to #include <windows.h> anyway |
| ||
| Re: Preprocessor #warning Command Question > #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. How to tell your OS/Compiler/etc at compile-time http://predef.sourceforge.net/ You have to do something like this #ifdef _WIN32 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:
|
| All times are GMT -4. The time now is 3:32 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC