自己裸机移植RTThread到STM32F407开发板上,想用C/C++混合编程,出现了以下问题
1.在C/C++下不添加“—cpp11“时显示
` Build target 'Target 1'
compiling main.c...
..\rt-thread\T.h(14): error: #20: identifier "class" is undefined
class CTIM
..\rt-thread\T.h(15): error: #65: expected a ";"
{
..\rt-thread\T.h(28): warning: #12-D: parsing restarts here after previous syntax error
};
..\rt-thread\T.h(39): warning: #1-D: last line of file ends without a newline
#endif
User\main.c: 2 warnings, 2 errors
compiling T.cpp...
T.h(39): warning: #1-D: last line of file ends without a newline
#endif
T.cpp: 1 warning, 0 errors
".\Obj\Template.axf" - 2 Error(s), 3 Warning(s).
Target not created.`
2.添加”—cpp11“之后显示
}
board.c: 1 warning, 0 errors
linking...
.\Obj\Template.axf: Error: L6218E: Undefined symbol rt_thread_create (referred from thraed.o).
.\Obj\Template.axf: Error: L6218E: Undefined symbol rt_timer_create (referred from thraed.o).
.\Obj\Template.axf: Error: L6218E: Undefined symbol $Super$$main() (referred from components.o).
.\Obj\Template.axf: Error: L6218E: Undefined symbol rt_thread_init (referred from idle.o).
.\Obj\Template.axf: Error: L6218E: Undefined symbol rt_hw_stack_init (referred from thread.o).
.\Obj\Template.axf: Error: L6218E: Undefined symbol rt_timer_init (referred from thread.o).
.\Obj\Template.axf: Error: L6218E: Undefined symbol rt_hw_hard_fault_exception (referred from context_rvds.o).
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.
Finished: 2 information, 0 warning and 7 error messages.
".\Obj\Template.axf" - 7 Error(s), 3 Warning(s).
查过百度和官方论坛,没找到问题的解决方法,想问问各位怎么解决
这个我是已经添加了的
c语言包含的头文件不可以有
class
, c的语法里没有‘类’。。。参见 https://blog.csdn.net/weicao1990/article/details/53462644
解决了,谢谢
请问您是怎么解决的?@帮大忙了
@做我喜欢
extern"C"
包裹的部分是C语言的代码,C++不能用写在extern"C"
修饰的内容里。