I have implemented C++ queue in my codes, those I run on my PC.
Now I'm programming an ATmega128 micro-controller to implement a
.c code. Can I use that
Will it work?
If not please suggest me a
queue to implement.
It is very well possible to use C++ on the AVR. Arduino has been doing it for ages. Unfortunately, avr-g++ does not ship with a C++ standard library (the successor to the old STL), so you have to rely on C++ core language features. C++, just like C, has many features that don't map well to small microcontrollers; you need to find out which ones. For starters, exceptions, RTTI (
delete, and anything that requires those (especially standard library containers like
queue) don't really work here. Typical microcontroller programs use ring buffers and fixed arrays instead.
On the other hand, classes (including virtual functions), templates/Metaprogramming,
constexpr, proper constants, avoiding macros, function overloads and RAII can be put to good use without sacrificing efficiency.
To compile C++ code, substitute calls to
avr-gcc with calls to
avr-g++. Make sure to use a recent version, since C++ support is in active development.
avrgcc is gcc and therefore it supports c++, but you have to tell it that you're compiling c++ if you want to use C++ syntax.
This may be as simple as using
.c++ as your file extension, or more complex depending on what your build chain is.