Do not allow enum typedef forward-declaration to comply with C99
standard chapter §6.7.2.2 point 4:

  Each enumerated type shall be compatible with char, a signed
  integer type, or an unsigned integer type. The choice of type
  is implementation-defined, but shall be capable of representing
  the values of all the members of the enumeration.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
 docs/devel/style.rst | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/docs/devel/style.rst b/docs/devel/style.rst
index 12e509d10de..5ab5c21447d 100644
--- a/docs/devel/style.rst
+++ b/docs/devel/style.rst
@@ -416,6 +416,17 @@ definitions instead of typedefs in headers and function 
prototypes; this
 avoids problems with duplicated typedefs and reduces the need to include
 headers from other headers.
 
+Enumeration (enum) type can not be forward declared as typedef, because
+C compilers should be able to know the size of enums before hand. Simply
+define the typedef along with the enum:
+
+.. code-block:: c
+
+    typedef enum MyEnum {
+        FOO,
+        BAR,
+    } MyEnum;
+
 Bitfields
 ---------
 
-- 
2.52.0


Reply via email to