trying to use C++ with CWv4.6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

trying to use C++ with CWv4.6

Jump to solution
7,077 Views
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?
Labels (1)
Tags (1)
0 Kudos
1 Solution
548 Views
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


View solution in original post

0 Kudos
4 Replies
548 Views
ElliottKevin
Contributor I

i agree with u..

__________________________________________________
Shocks and struts
Shock absorber
Ford shocks and struts

0 Kudos
548 Views
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 Kudos
548 Views
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 Kudos
549 Views
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 Kudos