please can you guys tell me how to use #error and #line.
please can you guys tell me how to use #error and #line.
Is this related to C. I afraid not! . Please be more specific
Don't you have a C book? If not, I'd suggest you buy one instead of asking how to use every single function and preprocessor directive. Also, consider using a search engine, which gives you hits like this and this, also things like this here and so on, and... well, you get the idea.
Quzah.
Hope is the first step on the road to disappointment.
Actually, it is. But it's fairly easy to find out what you need, as I've illustrated with only a bit of typing into the nearest search engine.Originally Posted by codomaniac
Quzah.
Hope is the first step on the road to disappointment.
>Is this related to C.
It is, as a matter of fact.
>please can you guys tell me how to use #error and #line.
#line gives you control over the macros __LINE__ and __FILE__. Those two are most often used in error reporting, but the need to reset them may arise in tool-generated source files that need to be associated at the line level with the original user-written file. A good example would be a preprocessor that makes signifigant changes yet still requires accurate symbolic debugging on the original source file. The syntax:
Makes changes to both __LINE__ and __FILE__. The syntax:Code:#line n filename
Only makes changes to __LINE__. Here's an example:Code:#line n
#error creates a compile-time error. It's usage is pretty obvious:Code:#include <stdio.h> int main(void) { printf("This should be line 9: %d\t%s\n", __LINE__, __FILE__); #line 12345 "Booga!" printf("This would be line 11 without #line: %d\t%s\n", __LINE__, __FILE__); return 0; }
Code:#if !defined(SOME_MACRO) # error "SOME_MACRO not defined" #endif
My best code is written with the delete key.
Oh i didnt know this. Thanks for pointing this to me and Prelude you really rock
while we are on the subject or the preprocessor,
what does #pragma do? i have looked around but i need to see an example of how its used.
>what does #pragma do?
In C89/90, #pragma is completely implementation dependent. For details on how it's used you need to look through your compiler's documentation. In C99, there are three standard pragmas, two for floating-point operations and one for complex number operations. Check your nearest C99 reference manual for details.
My best code is written with the delete key.
ok thanks