Topic : Ride7 and C++

Forum : ARM

Original Post
Post Information Post
June 18, 2012 - 10:47am
Guest

I'm trying to compile a simple C++ class with Ride7. I believe C++ is supported by Ride7 and the underlying GCC compiler, yes? However, whenever the compiler encounters a class, it gives me the following error:

expected '=', ',', ';', 'asm' or '__attribute__' before ''

I think the compiler is trying to compile the file as C only. The file is named with a .h extension, as it my class definition. The file, however, is not included in my project, rather it just sitting in one of my include folders. The corresponding .cpp file is included in my project.

Is there something I need to do in order to get C++ classes to compile in Ride7?

Replies
Post Information Post
+1
0
-1
June 18, 2012 - 10:56am
Raisonance Support Team

Hi,

If the file is named *.cpp, it will be compiled in C++.
If it is *.c, it will be compiled as C.

Your problem is I think that you are trying to compile a .h file, which makes no sense. (neither in C nor in C++)
To confirm this please try compiling the .cpp file (right-click on it, click Make), which should succeed, and then on the .h file, which should fail.
You should remove the .h file from the project. It will appear in the cpp file's dependencies after the first compiling, so you'll have it at hand. You don't need to add it in the project. If you really want to have it visible in the first level, you should exclude it from both the Build and the Link. Then it will not be compiled.

You could also take a look at the C++ example provided with Ride:
\examples\ARM\REva\STM32F103_Toggle_cpp

I hope it helps.

Vincent

+1
0
-1
June 18, 2012 - 12:45pm
Guest

My problem was solved by renaming my main.c to main.cpp.