Oct 06, 2015
03:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 06, 2015
03:29 AM
Hi,
Dave4 and C++ needs some manual help:
1) Call of DAVE.h has to be enclosed in extern "C":
extern "C" {
#include //Declarations from DAVE Code Generation (includes SFR declaration)
}
2) Preprocessor of C++ Compiler misses a symbol:
At Project -> Properties -> C/C++ Build -> Settings copy the Preprocessor symbol at C-Compiler to Preprocessor of C++-Compiler (for example XMC4500_F144x1024).
Best regards,
Wolfgang
Dave4 and C++ needs some manual help:
1) Call of DAVE.h has to be enclosed in extern "C":
extern "C" {
#include
}
2) Preprocessor of C++ Compiler misses a symbol:
At Project -> Properties -> C/C++ Build -> Settings copy the Preprocessor symbol at C-Compiler to Preprocessor of C++-Compiler (for example XMC4500_F144x1024).
Best regards,
Wolfgang
Labels
4 Replies
Not applicable
Oct 06, 2015
10:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 06, 2015
10:24 PM
Hi Wolfgang,
For compiling with C++, you can change the build properties.
Project -> Properties -> C/C++ Build -> ARM-GCC C Compiler
Command: "${ARM_GCC_HOME}/bin/arm-none-eabi-g++"
Regards,
Daryl
For compiling with C++, you can change the build properties.
Project -> Properties -> C/C++ Build -> ARM-GCC C Compiler
Command: "${ARM_GCC_HOME}/bin/arm-none-eabi-g++"
Regards,
Daryl
Oct 07, 2015
06:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 07, 2015
06:07 AM
Hi Daryl,
thanks for the tip, but there is one consequence: not only the C++ files are now processed by g++, but also all C files, especially the Dave files. There are discussions in the web, how much the object code differs if you process a C file by g++ instead of gcc, for example here:
http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc
My test says: at least the code size is not the same and I suppose there are risks, the Dave code compiled by g++ has not the same behavior as at the tests by Infineon using gcc. Or does Infineon test and debug the whole Dave code with gcc and g++? I would recommend it, because of the much stronger type checking of C++.
Best regards,
Wolfgang
thanks for the tip, but there is one consequence: not only the C++ files are now processed by g++, but also all C files, especially the Dave files. There are discussions in the web, how much the object code differs if you process a C file by g++ instead of gcc, for example here:
http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc
My test says: at least the code size is not the same and I suppose there are risks, the Dave code compiled by g++ has not the same behavior as at the tests by Infineon using gcc. Or does Infineon test and debug the whole Dave code with gcc and g++? I would recommend it, because of the much stronger type checking of C++.
Best regards,
Wolfgang
Oct 08, 2015
02:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 08, 2015
02:00 AM
also if you use any interrupts, you need to enclose them in main (took me a while to figure out, since the compiler doesn't warn here if you miss it, yet the ISR are never called)
Example:
extern "C" {
void ISR_Adc_Measurement(void)
{ ...}
}
Example:
extern "C" {
void ISR_Adc_Measurement(void)
{ ...}
}
Oct 08, 2015
07:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 08, 2015
07:42 AM
Hi Andyl,
yes, the same like at Dave3 (I mentioned only the news of Dave4, there are many entries in the forum concerning Dave3 and C++). In general, if Dave calls a function located in a c++ file, the function must use the name mangling of C, done by enclosing the C++ code in
extern "C" {
..
}.
The background: because of the possibility of function overlays in C++, functions with different arguments must have different names. Thus in contrast to C, at C++ the argument types are part of the function names. The caller of Dave expects a C style function name (without argument types in the name) and the linker doesn't find the function if you don't use 'extern "C" '.
Best regards,
Wolfgang
yes, the same like at Dave3 (I mentioned only the news of Dave4, there are many entries in the forum concerning Dave3 and C++). In general, if Dave calls a function located in a c++ file, the function must use the name mangling of C, done by enclosing the C++ code in
extern "C" {
..
}.
The background: because of the possibility of function overlays in C++, functions with different arguments must have different names. Thus in contrast to C, at C++ the argument types are part of the function names. The caller of Dave expects a C style function name (without argument types in the name) and the linker doesn't find the function if you don't use 'extern "C" '.
Best regards,
Wolfgang