enum{f,g=f};

F

Francois Grieu

Hi, is this valid?

enum{f,g=f};

The problem (if any) is that the value for g references f,
which is defined in an enum not yet completed.

TIA,
Francois Grieu
 
J

John

Hi, is this valid?

enum{f,g=f};

The problem (if any) is that the value for g references f,
which is defined in an enum not yet completed.

TIA,
   Francois Grieu

f == 0
g == 0
 
K

Keith Thompson

Francois Grieu said:
Hi, is this valid?

enum{f,g=f};

The problem (if any) is that the value for g references f,
which is defined in an enum not yet completed.

Yes, it's valid.

C99 6.2.1p7:

Each enumeration constant has scope that begins just after the
appearance of its defining enumerator in an enumerator list.

Note that an "enumerator" includes the "= constant" if present, so
"enum { x = x }" is illegal (unless another x was previously declared
in an enclosing scope, but that's ugly so don't do it).
 
F

Francois Grieu

Keith Thompson wrote :
Yes, it's valid.

C99 6.2.1p7:

Each enumeration constant has scope that begins just after the
appearance of its defining enumerator in an enumerator list.

Note that an "enumerator" includes the "= constant" if present, so
"enum { x = x }" is illegal (unless another x was previously declared
in an enclosing scope, but that's ugly so don't do it).
Thanks, that's exactly the reference & explanation that I was seeking.

Francois Grieu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top