在丢弃节中定义错误
Defined in discarded section error
我在头文件myStruct.h
中将结构类型定义为struct myStruct {...};
。
然后我在主体中声明了一个结构对象为:
myStruct s;
以同样的方式在类头中使用一次。
这不起作用,给出一个错误:
`_ZN10myStructC2Ev' referenced in section `...myClass...'
of.../module.pre.o: defined in discarded section
`.text._ZN10myStructC2Ev[_ZN10myStructC5Ev]' of .../module.pre.o
如果我在类中只有结构,它就可以工作,但我也需要它在main中。我该如何解决?
将其定义为:
extern myStruct s;
在头文件中。
相关文章:
- 使用命名空间时出现多个定义错误
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 尝试调用 .h 文件中定义的变量时出现变量未定义错误
- 在头文件和 cpp 文件中使用一次 #pragma 时出现结构重定义错误
- 链接阶段出现多重定义错误
- 避免模板类中的重定义错误
- 即使我没有包含多个文件,C++中的多个定义错误
- 跨多个类的全局变量而不会出现重定义错误?
- 尝试运行 wasm 函数时出现模块未定义错误
- C++ 预期的左大括号以及重定义错误
- C++:成员的越界声明必须是纯虚函数的定义错误
- c++中数组的未定义错误
- Visual C:模板类中的自定义错误消息
- 为什么C++模板不会导致多个定义错误?
- 只有一个定义/声明时标头声明变量的多堆定义错误
- C++ 在多个其他类中使用单个类 - 编译时出现多个定义错误
- 基类未定义.错误 C2504
- Q 斯坦达项重定义错误
- 可视化C++中的结构定义错误
- VC++ C2011 重定义错误 - 未使用的头文件