I,ve installed the Compiler and I can,t get even the simplest code to compile properely.
Anyone know where the fix for this bug is?
Or is it a limit of the demonstration version?
void main(void) { cout << "Hello world!"; }
Someone give a more positive (and helpful) response please!
It looks pretty helpful to me... You want a C++ compiler but the Keil compiler isn't.
I know how to write code using cout and expect my compiler to do it. Why so difficult to get a simple answer?
I believe your questions have been answered.
Are you aware that you are posting on an embedded toolset forum?
If you're simply looking for free stuff on a PC then check out the GNU compiler. http://gcc.gnu.org/ They also have their own forums for support.
-- Joost
I've found one at Ceibo :)
Even better is that they have a demo version.
www.ceibo.com/.../8051cpp.zip
I,ll give it a try and see if it does better than the limited Keil package.
I'm sorry to tell you this, but the Ceibo C++ compiler uses the Keil compiler. Any limits that the evaluation version of the C51 compiler has (regarding code size, memory map restrictions, etc) will thus be inherited by the "free demo" of the Ceibo compiler.
And since the evaluation version of C51 is limited to 4 kB code size, you will most likely run into problems when you use "powerful" (also known as "bloated") string output functions like cout or printf().
Are you aware that the Keil compiler will not produce any output that will run on a PC ? It is a compiler for 8051-based microcontrollers.
I like C++ for embedded work. I do not like to use the C++ libraries, because of their size.
Trying to use C++ to write code for a demo compiler with a 4kB limit is quite amusing. I whish you great luck. You will be very happy with your choice...
If your goal was to write programs for a PC, then good luck.
If you where really planning on writing programs for '51-chips, then I think it is time you try to read up on the processor architecture. Don't talk about limited compiler until you have figured out exactly how limited the processor is, when it comes to running high-level languages.
It's a bit interesting that whenever someone gives you an answer you don't like, you are rude towards them. Basically, you are the kind of guy would google for information. If the first 10 (or 100) links says something you don't like, you continue scanning links until someone gives the "correct" answer. Even the 100th link is at the 100th place because the contents of the document is wrong...
Why have a demo version that won,t compile my simple program?
Anyone got any other suggestions (please limit to ones that are both helpful and in English)?
Why have a demo of a C compiler that doesn't compile Ada?
Why have a demo of a C compiler that doesn't compile Pascal?
Why have a demo of a C compiler that doesn't compile Cobol?
Don't you still get it. C and C++ are two completely different programming languages. You may test any C compiler in the world. It doesn't matter. A C compiler just can not compile C++ programs. I say it once more: A C COMPILER IS COMPLETELY UTTERLESSY IMPOSSIBLY UNABLE TO COMPILE A C++ PROGRAM, SINCE C++ IS A COMPLETELY DIFFERENT LANGUAGE!!!
What does it take for you to realize that you are trying the wrong programming language?
Would it help if I say it in Swedish? En C-kompilator kan inte kompilera C++-program!
Other people on this forum might be able to help with other languages, since it seems obvious that you can't parse English...
What part of
"A C compiler will not compile C++ code."
is not clear to you ?
Even if you bought the full version of C51, it still would not compiler your C++ code, because
the C51 compiler is a C compiler.
Also, your program isn't "simple". It uses a string formatting and output function, and those are extremely powerful and complex, which translates into a very large code size. It can fill up a sizable portion of a 8051s memory without any problems.
For this reason, this type of function is usually avoided in embedded programming.
Thanks for your comments guys.
So, in brief, the demo of the Keil C compiler will not do what I want and nor will it even if I spend a few thousand bucks on it.
The ceibo might do it if I spend a few thousand bucks, but I cannot test it out on my complex one line program because it uses the Keil C compiler - Which (apparently) cannot compile C++ programs. This raises the question if Keil C cannot do it, why does ceibo come bundled with it?
Anyway, I need to know of alternatives and not just get you can,t do it style comments.
Can the SDCC compiler do it? It,s based on GNU tools I think so can I use the GNU C++ with that?
...my complex one line program...
Your trying to build your one line program for a 8051? Where will the "cout" output go?
From the website: SDCC is a retargettable, optimizing ANSI - C compiler
As stated in earlier posts: ANSI C is NOT C++.
Where will the "cout" output go?
cout = console output
I,ve been given some hardware with a display on it. A display makes a good console output.
So I need it to go to the display.
I know SDCC is a C compiler, but it is based upon GPL code so I think maybe someone hitches it to the GCC compiler chain.
Probable you think?
The ceibo might do it if I spend a few thousand bucks, but I cannot test it out on my complex one line program because it uses the Keil C compiler -
As I have said before: The problem you are going to run into if you use the Ceibo + Keil combination is that the evaluation version of Keil C51 only allows a code size of 4 kB. Any complex string formatting function (this includes printf and cout) will easily need upwards of 10 kB code space.
There's no need to use sarcastic bold letter. Any program that uses a string formatting function _is_ large and complex for a simple 8-bit microcontroller as the 8051.
This raises the question if Keil C cannot do it, why does Ceibo come bundled with it?
Because one way of compiling C++ programs is to use C as an intermediate step.
So a C++ compiler might translate a C++ program into a C program, and then a C compiler can be used to translate this C program to assembly. I would guess that this is the way Ceibo does it - this way they don't need to make their own C compiler (and they'll have a hard time trying to beat Keil or any of the other existing solutions).
If you had actually bothered to fully read the comments, you would have noticed several alternatives already. But I'll give you the list.
1. (this is not an alternative, but a prerequisite) Learn to extract useful information from human-readable text instead of being rude to the people who are, in fact, trying to help you. Use this skill to inform yourself about the particularities of the 8051 architecture (by reading the appropriate datasheets and the hardware documentation) and why C++ might not be a good language choice for this type of device. 2. Switch to a programming language that is more appropriate for a small device such as a 8051-type microcontroller. Plain C would be one such language. Your simple program would stay "simple", i.e. one line. (By the way, since you're trying to print text - where should the microcontroller output this text ? I did not see any intialization of an output device, for example a serial port)
I wouldn't think so. To make C usable on a 8051-type device, quite a few extensions need to be added to the C compiler. GNU C++ will not know these extensions. You may feel free to modify the GNU C++ compiler to your needs, however. It is free software, after all.
I,ve been given some hardware with a display on it.
... and the compiler is supposed to know about this how ?
A display makes a good console output.
It's nice and human-readable, but way, way more complex than, say, a serial port.
In that case, you'll need to write code that controls the display, or find some library that contains such code.
The compiler doesn't know about the hardware you're using.
The alternative you should look at is what languages that the majority of all developers uses when using '51 chips.
Some use C. Some use C. Then some use C. Most most of then tend to use C. Of the C users, some mixes in ore or less assembler, for the situations where a low-level high-level language is still too high-level.
I haven't looked at the compiler you mention, but there have since the birth of C++ existed C++ front-ends - parsers that takes C++ code, and mangles it into C code for use by a compiler. C++ was originally developed with C-Front.
Your simple line of code makes use of templates. I don't think you know too much about C++. If you did know C++, you would know the contents of the STL. You would know exactly how much code the compiler needs to mangle through to be able to decide what code to generate for that single line. You would also know how much run-time help that would be linked into your binary. On a PC, some compilers can manage to incorporate from 100k to more than 1MB for a trivial C++ binary that writes "Hello World" using cout.
It is now up to you to use your professionalism to consider the value of filling up most of the processor code space with runtime library code - even before you have started to implement an application.
Hint - how many microwave ovens have a need for a command line? How many intelligent battery chargers needs support for a path and environment variables? How many camera flashes needs a string datatype?
There are many ways to fail a project. You can be among the few who fails even before you have started - just by deciding that the two plus characters are the most important aspect of the project... The choice is up to you. If this is a school job - why fail before starting? If it is for a business - think about the badwill of the failure!
I,ve been given some hardware with a display on it. A display makes a good console output. So I need it to go to the display.
You'll probably need to do a bit more to get this working (display driver?).
I know SDCC is a C compiler
I wasn't sure because you didn't find this info for the Keil compiler.
but it is based upon GPL code so I think maybe someone hitches it to the GCC compiler chain.
I'm not sure what you mean with "hitching it to the GCC compiler". If you mean adding 8051 support to GCC (C++), I wouldn't call that "hitching" :-)
So, basically your question is: "does anyone know a free (as in beer and speech) C++ compiler for the 8051?". Is that correct?
Here's a couple of alternatives:
#1 - Go ahead with your plan to modify SDCC and the GCC compiler chain to produce 8051 C++ code.
#2 - Consider a way of working around the 4K limit of the demo compiler. Maybe split your program into 2 or more blocks each being small enough to produce an executable less than 4K. Not sure how you'd split your one line program up though.
But, be warned, I (and probably most) would consider neither to be practical.
Alternative: Can't you switch to C? Do you really need C++?
-- J