C VS C++ why have a 10k diffrence in codesize ?
Anubispod
Posts: 42
Hi i was playing around with a hello world demo and just added a float variable and the mathlib to it and did a atan . result compiled in C HUB LMM SPEED = 19.262bytes
and the almost the same in c++ toggle demo added a float do some math inc l atan , toggle led C++ HUB LMM SPEED = 2.232 bytes.
Why the huge size difference and what is the big downside from c++ then if its so small and tidy???
Best regards
Oliver. R
and the almost the same in c++ toggle demo added a float do some math inc l atan , toggle led C++ HUB LMM SPEED = 2.232 bytes.
Why the huge size difference and what is the big downside from c++ then if its so small and tidy???
Best regards
Oliver. R
Comments
This subject has been debated a lot here and I know C++ will generate excactly the same sized code for similar functionality as C, even when introducing object oriented programming. Sorry I don't have time to find the links to those earlier threads just now. Of course if you start to use math and streams and such you pull in a lot of extra overhead.
I think you have to show us your code that demonstrates what you are talking about.
I'd imaging C and C++ would be about the same size.
I've been told that C++ only gets bloated when you add in the "standard library" for things like cin and cout, etc.
and here are the 2 samples i have ...
propeller-elf-objdump -h a.out
Done. Build Succeeded!
propeller-load.exe -I C:/propgcc/propeller-load/ -b HUB -p COM7 a.out -e -r
Propeller Version 1 on COM7
Loading a.out to EEPROM via hub memory
2232 bytes sent
Verifying RAM ...
OK
OK
Edit: Can you send me the a.out file?
fom 2.2k to 19k wow
I totally agree. It's uncommonly flexible and useful.
BTW, I wish I'd said something like... On a memory-limited uC it's like sharing a twin bed with a Saint Bernard.
http://forums.parallax.com/showthread.php/147184-A-smaller-printf-...?p=1174740&viewfull=1#post1174740
most I imagine...
then, it's just a drop in a big pool...