i can not write cpp instruction in my header files like usual CPP ide (visual cpp) does keil support class definition just in X.cpp file ?
C++ does not have "instructions" - so what, exactly, do you mean?
i can not write cpp instruction in my header files like usual CPP ide
If you cannot write something, how's that a problem with Keil's compiler, rather than with, say, your editor or your keyboard?
In other words: what is stopping you from writing what you want? And what, exactly, is it you're trying to write, anyway?
as you know in c++ ,ability to use classes and objects is basic differences from borland or other type of c . by "does header file support C++ instruction" it is clear that header file support c code (we can write c code in header file in all of compilers ) but C++ code like "class {}" , "public:" , ... used just as declaration seems is not supported in header by keil
as you know in c++ ,ability to use classes and objects is basic differences from borland or other type of c .
Hmmm... the last compiler by Borland that didn't do C++ happened about 20 years ago...
by "does header file support C++ instruction" it is clear that header file support c code
Nothing even remotely like that can possibly be clear from that phrase.
used just as declaration seems is not supported in header by keil
And you're sure you didn't promise the Keil tools in any way, shape or form that you were only going to write C code in there? E.g. by only buying a C compiler instead of a C++ one, or by calling your proper source files foo.c instead of foo.cpp?
No, it is still not clear!
Again, C++ does not have "instructions" - so you need to explain what, exactly, you mean by it here. Until you do that, it will remain unclear!
"seems is not supported in header by keil"
What makes it "seem" that way to you?
ie, from what evidence do you draw that conclusion?
ok ,ok when the extension of my source is .CPP every thing is ok ,i can use class create objects... but when extension is .h the compiler report error on code like class{} ...
The springing point isn't .h but how it gets _included_ - from c file, c++ file or an assembler file.
What have you done to convince the compiler that it should be in c++ mode?
maybe he's trying to compile a .h file...
Which isn't illegal with regards to the language. But stupid. And requires that the tool is informed that it should be processed as a cpp file.
Indeed.
"But stupid"
But I'm not sure we can rule-out the possibility in this case...
you can of course write C++ code in a header file, but if you do so then it can only be included from a C++ source file.
there are a few exceptions to this in Keil, since it supports some C++ features even when compiling a C file, such as C++ style comments and anonymous unions / structures.
this is actually really useful.
But of course if you are building a project with existing C files and want to start using C++ features then you have to take care also with name mangling, so it's probably better to simply tell uVision that all files are to be compiled as C++ anyway.
You can select the file type for any file in the project by changing it's options.
regards
Phil.
Thanks Phil . I changed the options and problem solved .
http://www.keil.com/forum/20725/