c - Preprocessor error when defining = -


i trying awkward preprocessing , came this:

#include <stdio.h>  #define 6 =6  int main(void) {   int x=6;   int y=2;    if(x=six)     printf("x == 6\n");   if(y=six)     printf("y==6\n");    return 0; } 

gcc gives me errors:

test.c: in function ‘main’:
test.c:10:8: error: expected expression before ‘=’ token
test.c:12:8: error: expected expression before ‘=’ token

why that?

the == single token, cannot split in half. should run gcc -e on code

from gcc manual pages:

-e stop after preprocessing stage; not run compiler proper. output in form of preprocessed source code, sent standard output.

input files don't require preprocessing ignored.

for code gcc -e gives following output

  if(x= =6)     printf("x == 6\n");    if(y= =6)     printf("y==6\n"); 

the second = causes error message expected expression before ‘=’ token


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -