Hello,
which spezifications / header files are necessary to use the Realview compiler for c++?
I use
#include<stdlib.h> #include<iostream.h>
Class Array { private: int val[19]; public: int max = 2; };
But µVision don't know the word "Class" - is it the wrong spelling or is there a necessary headerfile missing?
best wishes Tina
instead of 'Class', use 'class'
there's no difference.. when I use class...
are there any settings I have to change for c++? Or is it only possible to use c++ with the whole RealTime MDK?
In which folder can I found the header files for c++?
I haven't tested to compile C++ code with the tool, but what file extension do you have on your source files?
I only get an .c file not an .cpp file.
Are there any settings necessary in the Options for target > c/c++ menue?
I'm not sitting near the tools, but even if it is possible to have c++ code in a *.c file, I don't recommend it. Always use the proper file extension.
that's true - I don't want to have any c code - only c++ code.
But I don't know how I can get a cpp file from uvision. Maybe you can take a look when you are in front of your tools, if there are settings I have to take.
Under settings->extensions the file extension *.cpp will support C++ while the file extension *.c will not support C++. You can mix files or you can change the extension defaults. Bradford
I don't know what you mean by "get a cpp file from uVision".
It should be enough to just create a *.cpp file and add to the project.
ok - I only have to change .c into .cpp - that's all? But what's the problem that uvision gets an error, when I write "class"?
The C++-unique keyword "class" does not exists in C, so uVision should complain, if a statement starts with "class" in a C file.
In C, you can declare a variable named class, i.e.
int class;
In older C compilers, you may declare variables with an implicit int data type, writing:
class;
But you will not manage to get a C compiler to like:
class Array { ... };
since that does not mean anything for a C compiler. If "class" was a function name (with an implicit int return type) then it should be followed by a '(' character for the parameter list. If "class" is a variable (of implicit int type) then it should be followed by a comma, a semicolon, a '[' or similar.
2 possible solutions:
a) use files with .cpp extension - this automatically enables the C++ language.
b) when using files with extension .c, then the --cpp command needs to be added to -
Options for Target - C/C++ - Misc Controls.
This will enable C++ for .c files, otherwise C90 is used by default.
thanks - that's seems to be the right way. Is it enough to add -cpp in the misc controls?
best regards Tina
ok it works - thanks for your help
"that's seems to be the right way"
I don't think so!
The "right" way, in my opinion, is to use the .cpp filetype to identify C++ files, and .c to identify pure 'C' files. (or, at least, to choose some other distinct, well-defined classification)
This is the way the tools expect it, the most obvious way, and the generally-accepted way.
It is also my experience that deliberately fighting against the tools, the obvious way, and general practice will cause you pain and grief in the future...