Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
What about dev-c++? Any1 who can reccomend it, or is there any better compilers for c++?
And for you who know a bit about C++ code language, is this code suppose to show a result on the screen after compiling and running it, or is it ment to be showed on a mini LCD screen on a microcontroller?:#include <iostream>using namespace std;int main (){ cout << "Hallo"; return 0;}
So if I understand this correctly, I can use C++ to program my AVR chips, I just can't use AVR Studio to compile it right? I will have to compile it via command line.
Quote from: MarkBrown on August 30, 2008, 06:02:40 PMSo if I understand this correctly, I can use C++ to program my AVR chips, I just can't use AVR Studio to compile it right? I will have to compile it via command line.CorrectSo with the avr compiler and Notepad you have everything you need to create C++ code.
Ignore all the comments about 'C++ is not for microcontrollers'. Anything that the C guys do, I can do in C++ and it will be no bigger and run just as fast. But even better - when you compare a C program that uses, say, 3 sonar sensors then I'll bet you my code is smaller. The only way the C guys can compete is by using 'structures' - but then they are just spending time to write in C what the C++ compiler does for you automatically. But they still cant do method overloading etc. I've yet to get a sensible explanation from anyone as to 'why' they think 'C++ is overkill' with some coding examples!! Unlike the Java runtime, C++ doesn't require any runtime interpreter so the code can be just as tight as it is in C - if not better. And the benefits of encapsulation etc make your code robust and re-usable. I do ALL of my AVR software projects in C++
Quote from: sotu on August 31, 2008, 03:12:50 PMYour code will show Hallo in a command window, although depending on the compiler it could show and hide faster than you can see the results.
Ignore all the comments about 'C++ is not for microcontrollers'. Anything that the C guys do, I can do in C++ and it will be no bigger and run just as fast. But even better - when you compare a C program that uses, say, 3 sonar sensors then I'll bet you my code is smaller. The only way the C guys can compete is by using 'structures' - but then they are just spending time to write in C what the C++ compiler does for you automatically. But they still cant do method overloading etc. I've yet to get a sensible explanation from anyone as to 'why' they think 'C++ is overkill' with some coding examples!!
Quote from: Webbot on August 31, 2008, 04:24:46 PMIgnore all the comments about 'C++ is not for microcontrollers'. Anything that the C guys do, I can do in C++ and it will be no bigger and run just as fast. But even better - when you compare a C program that uses, say, 3 sonar sensors then I'll bet you my code is smaller. The only way the C guys can compete is by using 'structures' - but then they are just spending time to write in C what the C++ compiler does for you automatically. But they still cant do method overloading etc. I've yet to get a sensible explanation from anyone as to 'why' they think 'C++ is overkill' with some coding examples!! Right, to a certain point. For example, in the library you showed me, you're handling it a little ineffecient. When reading through it I saw you created a LED class with a toggle function. This means you store the current state in a variable. Sometimes you don't need this variable to store whether the pin is high or low. I agree with you that 1 bit is a very small value, and it won't affect the memory usage a lot. But it still affects memory. I would create a base LED class, and a derived ToggableLed class.Not attacking you, just giving you ideas for your library
If the program is so big and complicated that OOP's methodology provides significant and real benefits, then probably 8-bit microcontroller is not the right solution.
So using OOP in C is a Good Thing™.
Suggest you re-do your research. The 'toggle' function for the LED class is inherited from the OUT (ie outpin pin class) it just does a bit-wise exclusive-or with the current output value. Just like the C avrlib library does. So requires 'ZERO' memory.
Compilers generate code to do what we've asked them to do. Sometimes we aren't very good at optimizing what 'we' tell the compiler to do.
Admin: do you mean a tutorial on programming from the ground up? Optimization etc?Yeah - I could be up for it
Not a tutorial on programming (there are a million out there), but a tutorial on optimizing code.Basically a tutorial that will make my code optimal like your code
Yes, the use of pointers.
now the stupid question can the Axon handle c++