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!"; }
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++.
-- Joost
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
Ok guys,
Looks like I'm not getting through to you here!
You make these comments without knowledge or appreciation of the requirement.
My contract requires me to produce code for an 8052 controller board that has a keypad and a display.
I need serious options please.
hopeless issue
if (s)he does not understand the difference between C and C++ what will the next question be?
Of course, is a major fault of the '51 that is is good at what it is designed for and not for what the OP wants. YES, fault of the '51, not 'fault to the toolmakers', trying to make the '51 execute C++ bloatware is even more ridiculous than supporting function pointers/malloc etc. At least they (except ceibo) stopped there.
The ceibo product is NOT a C++ compiler, it is a C++ to C converter.
Erik
Well, you've discounted the hints and opinions of several experienced developers. I think the issue of who isn't getting through to whom is acutally reversed.
Well, it's not like you completely left us guessing at what the requirements were, right ?
Well, why didn't you say so ?
If your contract doesn't explicitly state that C++ must be used, then you are free to use a much, much more appropriate language for the microcontroller in question, such as C.
And after you have made this decision, you can proceed to the real time-consuming parts of your task. Like reading the datasheets of the keypad and the display and write the appropriate code so your '51 can actually communicate with these devices (no, your compiler won't do that for you. It knows exactly nothing about the peripherals attached to your MCU. May, if you're really lucky, you can find libraries, but I wouldn't count on it).
"Looks like I'm not getting through to you here!"
On the contrary - it's the return path to you that isn't working.
You seem totally unable to understand that C and C++ are different programming languages.
"You make these comments without knowledge or appreciation of the requirement."
nobody can know your requirement if you haven't stated it!
"My contract requires me to produce code for an 8052 controller board that has a keypad and a display."
I see no requirement there to use C++
Where is the requirement that the programming language used must be C++ ??
"I need serious options please."
Why do you not consider writing in 'C' to be a serious option?
However, if you do have a bona-fide commercial requirement for an 8051 C++ compiler, you should speak directly to the people at Keil and/or Ceibo and see if you can negotiate terms on a suitable evaluation...
Also, Hitex used to offer short-term licences for the full Keil toolchain (still C-only, remember) - I don't know if they still do; you can ask them: http://www.hitex.co.uk/