Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > c symbols with different meanings in different contexts
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 18th January 03:07
amit.codename13
External User
 
Posts: 1
Default c symbols with different meanings in different contexts



in the statement

int a=1,2;

i get the following error with a gcc compiler

/home/amit/main.c||In function ‘main’:|
/home/amit/main.c|6|error: expected identifier or ‘(’ before numeric
constant|
||=== Build finished: 1 errors, 0 warnings ===|

the error suggests that either we put a identifier after the comma :
int a=1,b;

or we put a '(' before numeric constant :
int a=(1,2);

so one makes comma act as a initializer list separator and the other
makes it act as a comma operator...

so what may be actual reason for generation of the error...


does it violate the constraints in the syntax of a comma operator or
in the syntax of declarations...

how does the standard deals with symbols with different meanings in
different contexts
  Reply With Quote


  sponsored links


2 18th January 03:08
robert steed
External User
 
Posts: 1
Default c symbols with different meanings in different contexts



The "actual reason for the error" is that the statement doesn't make sense.
Not to humans nor compilers.

in the statement

int a=1,2;

i get the following error with a gcc compiler

/home/amit/main.c||In function ‘main’:|
/home/amit/main.c|6|error: expected identifier or ‘(’ before numeric
constant|
||=== Build finished: 1 errors, 0 warnings ===|
<snip>
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666