Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > preprocessor

Reply
Thread Tools

preprocessor

 
 
sangeeta chowdhary
Guest
Posts: n/a
 
      06-30-2010
Hi,

I have compiled this code-

#include<stdio.h>
int main()
{
#ifdef NOTE
/* unterminated comment
int a;
a=10;
#else
int a;
a=20;
#endif

printf("%d\n",a);
return 0;
}

Now,#ifdef fails in this case and the if block doesn't go for
compilation,still errors in the if block are not permitted,how? Who
check for these errors? I heard about compile time errors,logical
errors,run time errors then in which category this error come? If
syntax error,but compiler checks for syntax error ,but this error is
displayed before compilation.


}
 
Reply With Quote
 
 
 
 
Fred
Guest
Posts: n/a
 
      06-30-2010
On Jun 30, 9:10*am, sangeeta chowdhary <(E-Mail Removed)>
wrote:
> Hi,
>
> I have compiled this code-
>
> #include<stdio.h>
> int main()
> {
> * #ifdef NOTE
> * * /* unterminated comment
> * * int a;
> * * a=10;
> *#else
> * * int a;
> * * a=20;
> *#endif
>
> *printf("%d\n",a);
> *return 0;
>
> }
>
> Now,#ifdef fails in this case and the if block doesn't go for
> compilation,still errors in the if block are not permitted,how? Who
> check for these errors? I heard about compile time errors,logical
> errors,run time errors then in which category this error come? If
> syntax error,but compiler checks for syntax error ,but this error is
> displayed before compilation.
>
>


Comments are removed BEFORE ifdef's are processed.
--
Fred K
 
Reply With Quote
 
 
 
 
Peter Nilsson
Guest
Posts: n/a
 
      07-01-2010
sangeeta chowdhary <(E-Mail Removed)> wrote:
> * #ifdef NOTE
> * * /* unterminated comment
> * * int a;
> * * a=10;
> *#else
>
> ...this error is displayed before compilation.


Translation phase 3 is decomposition into preprocessing
tokens. Preprocessing directives are not processed until
translation phase 4. [cf. 5.1.1.2p1]

--
Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
C# Preprocessor =?Utf-8?B?SSBhbSBTYW0=?= ASP .Net 2 03-13-2005 02:47 PM
preprocessor, token concatenation, no valid preprocessor token Cronus C++ 1 07-14-2004 11:10 PM
VHDL Preprocessor The Weiss Family VHDL 2 07-14-2004 05:51 AM
Preprocessor conditional compilation variable not being saved Chris P ASP .Net 0 10-28-2003 08:48 PM



Advertisments