Re: resolving a warning error

From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 10/28/04


Date: 28 Oct 2004 16:50:34 GMT

In <2379dacc.0410271530.531989ef@posting.google.com> pottmi@gmail.com (michael potter) writes:

>I would like to code a prototype that returns an enum, but not declare
>the enum.
>
>This works on several systems and compilers, but fails on aix xlc.

Not if you invoke them in conforming mode:

    fangorn:~/tmp 200> gcc test.c
    fangorn:~/tmp 201> icc test.c
    fangorn:~/tmp 202> gcc -ansi -pedantic test.c
    test.c: In function `main':
    test.c:8: warning: ISO C forbids forward references to `enum' types
    fangorn:~/tmp 203> icc -Xc test.c
    test.c(8): warning #102: forward declaration of enum type is nonstandard
      enum anEnum someFunc(void);
           ^
The diagnostic is *required* by the C standard:

     6.7.2.3 Tags

     Constraints

1 A specific type shall have its content defined at most once.

2 A type specifier of the form

              enum identifier

     without an enumerator list shall only appear after the type it
     specifies is complete.

>How can I eliminate that warning message without eliminating other
>warning messages and without declaring the enum?

Your only chance is to find a way of invoking xlc in nonconforming mode,
because a conforming compiler MUST generate it, but you *really* don't
want to do that.

Dan

-- 
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de
           Currently looking for a job in the European Union


Relevant Pages

  • Re: Segmentation Fault....
    ... Neither way is the true path to enlightenment, so to each his or her own. ... but heathfield insists that anything different from ... compilers largely don't support C99 yet. ... invoked in conforming mode, they do indeed produce a diagnostic. ...
    (comp.lang.c)
  • Re: enum safety
    ... 'Although variables of enum types may be declared, compilers need not ... In this case, c is of type char*, purple is of type enum ... creates a series of constants (which, oddly enough, are of type int, ...
    (comp.lang.c)
  • Re: function -> macro
    ... GCC and other C compilers now support many of the new features of C99. ... or ISO/IEC 9899:1999 when invoked in conforming mode. ...
    (comp.lang.c)
  • Re: function -> macro
    ... GCC and other C compilers now support many of the new features of C99. ... or ISO/IEC 9899:1999 when invoked in conforming mode. ...
    (comp.lang.c)
  • Re: Header files with enums instead of defines?
    ... You also can't #ifdef an enum. ... in those compilers you would have ... to define 'xerror' as 'enum ERRVALS xerror', ...
    (freebsd-arch)