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!"; }
what is it the compileer you installled?
keil c????
if you be answer keil c then code you give is bad and not compiler
you code is c++ but compile is c
c not thinking about cout like this you be not good and give errror
Can someone answer my question in English please!
I now know that not only is C++ available it can also be practical.
Did you try it out yourself, or did you conclude it from the advertisements of the compiler makers ?
What I find most bizarre is the attitude of some posters of this thread who assume to know what my precise requirements and desires are.
If you had asked the question
"I want to program an 8051 and I want to do so in no other programming language than C++, please tell me which compiler to use.", this thread would have been about three or four postings long.
But you seem to prefer to keep everyone in the dark and guessing.
You also seem to like pseudonymous posters with a disposition to trolling more than people who actually post under their real name.
I believe you actually came here for fun instead of advice. Some people like ... heated discussions. Was it fun so far ?
"Did you try it out yourself, or did you conclude it from the advertisements of the compiler makers ?"
I have now downloaded, installed and successfully compiled a couple of simple C++ programs.
FYI, at the start of the thread I was (as I admitted) not aware of the nuances. I could not have been as precise as you think I should have been. But I have had a busy 24 hours and I think learnt a lot.
Heated discussions. Hmmm. I think an individual text area for a message is not long enough to describe my thoughts concerning some of the responses I have had on this thread.
Fun is definitely not a word I would use in this context!
FYI, at the start of the thread I was (as I admitted) not aware of the nuances.
Where did you admit to not knowing about the "nuances" between C and C++? As I read it, you expressed quite a lot of explicit irritation that you didn't got the "correct" answer.
Users with meaningful questions and reasonably polite behaviour do almost always get meaningful responses, and mostly in a polite way. The only irritating answers I use to see is a bit high percentage of bold-faced Please read the manual, which I think is too hard an initial answer and better reserved for repeat offenders. But people do get reasonable answers. If they expand their queries with more followup information, the answers are expanded to be more precise.
If a poster breaks his back to rub everyone backwards and complaining about stupid answers - because the answer wasn't the expected - then threads do go down the drain. You really entered this thread narrowminded and with a huge amount of attitude. Are you surprised at the outcome?
I was merely trying to point out the fact that 'experience' does not necessarily equal knowledge. You just happened to be the one who posted a particularly good example.
I'm curious - did you just pick a number out of thin air to try and make a point, or did you actually believe that printf() was at least 10k of code?
"Where did you admit to not knowing about the "nuances" between C and C++?"
He did finally admit it - Posted 20-Jun-2007 01:28: "At the start I didn't realise about the precise differences in product capabilities."
But that was after 2 days and several dozen posts of vehemently refusing to hear it!
Even now, he still doesn't seem to have grasped that the difference lies in the fact that C and C++ are different languages - it's not just a matter of "precise differences in product capabilities"!!
The interesting thing with printf - and you can see examples of it if you search this forum - is that the Keil tools are good at analyzing how you use it.
printf() can require linking of more or less code. In this case, you didn't actually perform any "formatting", so you got a minimalistic overhead.
The concept isn't new. Old MSDOS developers probably remember TurboC that constantly failed to print floating point numbers unless at least one floating point math function where referenced in the source. The MSDOS linkers didn't have enough information to know what formatting parameters that was used by printf.
You think so?
Integer formatting:
#include <stdio.h> void main(void) { int d=1; printf("Hello world %d\n",d); while(1); } 000003H 00035EH 00035CH BYTE UNIT CODE ?PR?PRINTF?PRINTF
No formatting:
#include <stdio.h> void main(void) { float f=1.0; printf("Hello world\n"); while(1); } 00051BH 000989H 00046FH BYTE UNIT CODE ?PR?PRINTF?PRINTF
Floating point formatting:
#include <stdio.h> void main(void) { float f=1.0; printf("Hello world %f\n",f); while(1); } 00051BH 000989H 00046FH BYTE UNIT CODE ?PR?PRINTF?PRINTF
Doesn't seem to be much analysis going on there.
"Doesn't seem to be much analysis going on there."
There is obviously sufficient analysis going on to allow it to omit a load of stuff if the program uses no floating point.
Presumably, if the program contains floating point and uses printf, the compiler cannot safely assume that there aren't any dynamically-created floating-point formats - so it just has to include them, just in case...
"There is obviously sufficient analysis going on to allow it to omit a load of stuff if the program uses no floating point."
From previous experience of Microsoft compiler technologies, I would say that it is not so much analyzing that the stuff can be omitted but rather that they should not be included.
Specifically - When floating point is required in a module, it makes reference(s) to any external functions that are required for the compiler chosen task.
At link time these external references would normally pull in the libraries that satisfy the external references.
So - It is not normally the formatting string of the printf that is interpreted by the compiler to determine whether the libraries that are included, but rather the fact that a floating point access is somewhere in the project.
Remember people, C is even more limited!
Just curious, but how is C more limited than C++?
That's like saying that assembly is more limited than C. Or, that the Russian language is more limited than German.
Jon
Yes. But that doesn't require, or imply, any analysis of the printf() calls themselves.
Presumably, if the program contains floating point and uses printf, the compiler cannot safely assume that there aren't any dynamically-created floating-point formats - so it just has to include them, just in case.
Indeed.
I want to use C++ because I know C++.
Sure, but be honest and say "I have no idea of anything else, if C++ is right for this job or not does not matter"
NOW DO ANSWER have you ever done ANY small embeeded before, we all know that the answer is 'no' but it would be nice to hear it from you.
Erik
In this instance, dismissing C++ out of academic principal I would say is narrow minded. NOBODY has "dismissed C++ out of academic principal" many have "dismissed C++ out of knowledge of the architecture of the '51"
The problem you are going to run into if you use the Ceibo + Keil and you reply
void main(void) { printf("Hello world\n"); while(1); }
where does the Ceibo C++ come in, in the above mr smokied sardine
void main(void) { printf("Hello world\n");
while(1); }
Oh dear, here we go again.
I quoted two sentences as follows:
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.
You snipped this down to half a sentence:
The problem you are going to run into if you use the Ceibo + Keil
Thereby removing all the content I was actually replying to.
You then quoted part of my response, this time snipping out all the text that gave meaning to the code snippet.
Go back and read my post again. If you still do not understand it let me know and I will explain it to you in whatever level of detail is necessary.
I do not give a hoot about your post, the subject of this thread is NOT that printf works in C, which we all know, but C++ on the '51.
Erik,
I think in this case you really have missed Jack's point. He was showing the m51 file to indicate the using printf() in Keil didn't increase the code by 10kB, but rather by 1kBish which was an order-of-magnitude less "badness" than the original statement. It had nothing to do with C++, but was just continuing illustration of what he sees as bad in the responses on this forum -- namely that sometimes the estimates people provide from experience can be exaggerated and overly-emphatic.
Also, just as a point of reference for your future usage: The name he's chosen (Jack Sprat) doesn't have anything to do with sardines. It's from an old nursery-rhyme (though I don't know it's origin) that begins like this: "Jack Sprat could eat no fat. His wife could eat no lean."
-Jay Daniel
Also, just as a point of reference for your future usage: The name he's chosen (Jack Sprat) doesn't have anything to do with sardines.
I know that, but sardines are canned :)
"[Jack Sprat] was showing the m51 file to indicate the using printf() in Keil didn't increase the code by 10kB, but rather by 1kBish"
But did it show that?
It showed that the size of ?PR?PRINTF?PRINTF is 1K-ish, but it doesn't consider what other stuff may also get pulled-in as a result of having printf that wouldn't other wise have been included.
I haven't had the time for a detailed look at the map file, but the summary line from building a simple "Hello, world" example as shown indicates that the total CODE space usage is on the order of 2K...
It probably also varies with the Memory Model chosen...
So: still not 10K, but it certainly does show that a simple printf can easily use up virtually the whole CODE size limitation of the Evaluation version...!
A quick glance would be sufficient to spot the following line:
C:000000H C:000000H C:007FFFH 000438H CODE
Which shows the total code size to be 1080 bytes.
As usual you are commenting on what you would like me to have said, or what you imagine I have said, rather than what I actually have said. If you had the wit to read and understand my post you might be able to make some sort of sensible contribution.
I'm quite happy for you to criticise anything I write on this forum, but please don't keep muddying the waters by criticising things I haven't written. It wastes even more bandwidth than I already expend trying to get you to stick to the facts.
View all questions in Keil forum