I have my following functions declared in stack.h file and when I compile my project an error Unknown type name is been shown for l_ifc_handle.
extern l_bool l_ifc_init (l_ifc_handle iii);
extern void l_ifc_wake_up (l_ifc_handle iii);
extern void l_ifc_rx (l_ifc_handle iii);
extern void l_ifc_tx (l_ifc_handle iii);
extern l_u16 l_ifc_read_status (l_ifc_handle iii);
extern void l_ifc_aux (l_ifc_handle iii);
extern l_u16 l_sys_irq_disable (l_ifc_handle iii);
extern void l_sys_irq_restore (l_ifc_handle iii);
But my l_ifc_handle
is structure variable in another file called driver.h and used in driver.c
typedef enum {
LI0
}l_ifc_handle;
This driver.h file includes my stack.h header file. But the l_ifc_handle
is in my driver.h file.
If I use
typedef enum {
LI0
} extern l_ifc_handle;
then it gives an error called multiple storage classes. In which file should I place the above typedef?
extern
from the typedef.extern
is used for variables, not for types. – Klas Lindbäck Jan 25 '18 at 13:05extern
, then be sure that thetypedef
is visible in all units where you refer to it, before the use. This because in standard language you cannot create forward reference for enums (while GCC allows it as custom extension). – Frankie_C Jan 25 '18 at 13:17l_ifc_handle
as shown is not a structure type — it is an enumeration type with a single enumerated value (and that's equivalent to0
). The rules onenum
types are more stringent than those for structure types; you can't simply forward declare an enumeration — especially when the enumeration has no tag. – Jonathan Leffler Jan 25 '18 at 14:27