我正在尝试struct
在函数中传递指针。我typedef
在 file1.h 中有一个,并且只想将该标头包含到 file2.c,因为 file2.h 只需要指针。在 C++ 中,我会像在此处那样编写,但使用 C99 则行不通。如果有人对如何在struct
没有完整定义的情况下传递指针有任何建议,将不胜感激。编译器 - gcc。
文件1.h
typedef struct
{
...
} NEW_STRUCT;
文件2.h
struct NEW_STRUCT;
void foo(NEW_STRUCT *new_struct); //error: unknown type name 'NEW_STRUCT'
文件2.c
#include "file2.h"
#include "file1.h"
void foo(NEW_STRUCT *new_struct)
{
...
}