This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: prototyping functions returning an enum, before the enum is defined


"Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:

|> 	Some config/*/*.c files have extern functions returning an
|> enum of some sort.  Eg, function_arg_padding() in sparc.c which
|> returns an `enum direction'.  I'd like to be able to prototype these
|> in sparc.h, but we don't have the definition of `enum direction' from
|> expr.h yet.
|> 
|> 	Is it legal in both KNR and ANSI C to say:
|>  > extern enum direction function_arg_padding();
|> 
|> before `enum direction' has been defined?
|> 
|> 	What about doing:
|>  > enum direction;
|>  > extern enum direction function_arg_padding();

Both are wrong.  ANSI C does not have forward declarations of enum types.
>From the C9x draft (6.5.2.3 Tags):

       [#2] A type specifier of the form

               enum identifier

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

I'm pretty sure that this is unchanged from the current standard.

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"
schwab@gnu.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]