trying to use C++ with CWv4.6

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

trying to use C++ with CWv4.6

跳至解决方案
7,357 次查看
sricker
Contributor I
I am starting my second attempt at compiling C++ with CWv4.6 pro for HCS12(x).
I create a new project for DG256, C++ only, ANSI startup code. I compile after creation with no problems. Then I open class browser a create a new class with just a constructor and destructor. I can no longer compile. class keyword is not recognized so I get an "expected ;" error. So then I open the target settings and see that in the language tab C++ is not checked. WHY NOT? I selected C++ as the language already, did I not? So I figure I got it. Nope. Now I get L1115, _EntryPoint not found even though it is in cpu.c.
 
So what's up? Anyone?
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
828 次查看
CompilerGuru
NXP Employee
NXP Employee
The cpu.c as I saw it beeing generated does not give the "EntryPoint" symbol a C linkage when compiled as C++. It does not help to suspend PE or to rename cpu.c to cpu.cpp, the incompatible C++ to C linkage (in respect to the name mangling) does not get solved this way.

So you to do either
- have to refer to EntryPoint using its mangled name in the prm (use disassemble to find out the exact name)
- change cpu.c (.cpp) to give EntryPoint a C linkage (by adding
#ifdef __cplusplus
extern "C"
#endif
in front of every declaration and the definition
- compile cpu.c as C code and your user modules as C++ code. Add a extern "C" gard around included PE files
extern "C" {
 #include "processor expert headerfile.h"
}

Daniel


在原帖中查看解决方案

0 项奖励
回复
4 回复数
828 次查看
ElliottKevin
Contributor I

i agree with u..

__________________________________________________
Shocks and struts
Shock absorber
Ford shocks and struts

0 项奖励
回复
828 次查看
CompilerGuru
NXP Employee
NXP Employee
The normal C++ setup is to use files with *.cpp extension, not to force to compile any *.c files in C++ mode. Given your description, I think that is what happened for you. You used the wizard to create a C++ class in a C file, did not compile, then you forced every C file to be compile as C++ and you discovered that it was not prepared to be compiled as C++.
In order to use C++, I would suggest to name your C++ files with a *.cpp extension.

About this _EntryPoint missing declaration. It looks like the Processor Expert CPU bean file cpu.c does not support to be compiled as C++. I'm not sure if Processor Expert is supporting C++.

0 项奖励
回复
828 次查看
sricker
Contributor I
I changed files to cpp extension. Still the same problem. Who would know if processor expert is causing the problem? I suspend processor expert to no avail. Has ANYONE done this before? Here I am on the freescale forum and nobody knows how to set up and use C++ code with CW for 16 bit? Why is that? Is it just impractical and so it isn't done?
0 项奖励
回复
829 次查看
CompilerGuru
NXP Employee
NXP Employee
The cpu.c as I saw it beeing generated does not give the "EntryPoint" symbol a C linkage when compiled as C++. It does not help to suspend PE or to rename cpu.c to cpu.cpp, the incompatible C++ to C linkage (in respect to the name mangling) does not get solved this way.

So you to do either
- have to refer to EntryPoint using its mangled name in the prm (use disassemble to find out the exact name)
- change cpu.c (.cpp) to give EntryPoint a C linkage (by adding
#ifdef __cplusplus
extern "C"
#endif
in front of every declaration and the definition
- compile cpu.c as C code and your user modules as C++ code. Add a extern "C" gard around included PE files
extern "C" {
 #include "processor expert headerfile.h"
}

Daniel


0 项奖励
回复