我无法排序编译时错误.我正在编译C项目.我的main.c文件有一个#include,它可以获取我正在为我的项目使用的结构的定义.关键是每次我尝试编译我的代码时都会出错
struct Mystruct* ps = (struct Mystruct* )malloc( sizeof(Mystruct) ); // I have this
// error at compile time
error: 'Mystruct' undeclared (first use in this function)
Run Code Online (Sandbox Code Playgroud)
如何编译器无法读取结构定义?包含文件夹已正确设置
谢谢
mkb*_*mkb 19
听起来你需要sizeof(struct Mystruct)在表达中使用或使用typedef struct Mystruct Mystruct某个地方.在C中,结构有自己的命名空间.