为什么typedef不能用于静态?例如,下面的代码是错误
typedef static int INT2;
Run Code Online (Sandbox Code Playgroud)
使用typedef应该遵循哪些其他规则?还有哪些其他关键字不能与typedef一起使用?
非常感谢!
由于typedef是C中的存储类,因此不能与static变量一起使用.例如typedef static int SI,SI a是行不通的.那么有没有任何其他方式使用static与typedef?
我已经知道这可以做到#define SI static int.
我在 stack.h 文件中声明了以下函数,当我编译项目时,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);
Run Code Online (Sandbox Code Playgroud)
但我的l_ifc_handle结构变量位于另一个名为 driver.h 的文件中,并在 driver.c 中使用
typedef enum {
LI0
}l_ifc_handle;
Run Code Online (Sandbox Code Playgroud)
这个 driver.h 文件包含我的 stack.h 头文件。但它l_ifc_handle在我的 driver.h 文件中。
如果我使用
typedef enum {
LI0
} extern l_ifc_handle;
Run Code Online (Sandbox Code Playgroud)
然后它会给出一个称为多个存储类别的错误。我应该将上述 typedef 放在哪个文件中?