Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11281) [C++] forward enum declaration in common/fc_typ
Home

[Freeciv-Dev] (PR#11281) [C++] forward enum declaration in common/fc_typ

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11281) [C++] forward enum declaration in common/fc_types.h
From: "Frédéric Brière" <fbriere@xxxxxxxxxxx>
Date: Wed, 1 Dec 2004 01:56:59 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11281 >

common/fc_types.h has the following typedef:

  typedef enum specialist_type Specialist_type_id;

common/city.h includes that file:

  #include "fc_types.h"

and *then* proceeds to define enum specialist_type:

  enum specialist_type {
    SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_LAST
  };


This is a forward declaration of an enum, and is actually invalid under
C89 and C99, as well as C++.  (gcc will trigger an error in pedantic
mode.)  C compilers tend to be lenient about this, but C++ compilers are
more stringent. [*]

There are three possible solutions:

  - Moving the enum before the typedef

  - Moving the typedef after the enum

  - Changing the typedef for a #define


I don't think I'm qualified to make that decision, so I'll let you
figure out what to do.


[*] They have to.  But then again, they could make an exception for a
simple typedef.  It's just too much hassle for what it's worth.

-- 
             Frédéric Brière    <*>    fbriere@xxxxxxxxxxx

 =>  <fbriere@xxxxxxxxxx> IS NO MORE:  <http://www.abacomsucks.com>  <=





[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11281) [C++] forward enum declaration in common/fc_types.h, Frédéric Brière <=