Undefined reference to 'operator delete(void*)'

前端 未结 4 2114
长发绾君心
长发绾君心 2021-02-12 22:09

I\'m new to C++ programming, but have been working in C and Java for a long time. I\'m trying to do an interface-like hierarchy in some serial protocol I\'m working on, and kee

4条回答
  •  耶瑟儿~
    2021-02-12 22:36

    I will just quote the documentation, since they put it better.

    Writing C++

    You can write programs for the AVR platform in C++, if you included c++ in the enabled-languages during configuration of avr-gcc. Just about everything in the Writing C AVR programs section applies, so read that first.

    The major drawbacks of using C++ are:

    C++ calling convention side-effects
    No libstdc++ support.
    

    C++ calling convention side-effects

    Certain C++ features will automatically generate implied code if required, which can waste valuable program memory space and processor time. For instance, if at some point in the program a function is passed a C++ object by value:

    void myfunction(MyCppClass object);
    

    You will wind up with a default copy constructor being generated and called to create the temporary copy of object used in myfunction(). Be careful if this isn't what you want: equivalent behavior should be attainable by passing a reference to a constant MyCppClass object, while avoiding the code and execution overhead.

    Missing libstdc++ and other C++ features

    None of the C++ standard templates, classes or functions are available. In addition, operators new and delete have yet to be implemented.

    C++ exception support is also lacking. You'll probably need to make sure to use the -fno-exceptions compiler option to turn off the exceptions in the C++ front-end.

    What does work? Even though lots of the C++ goodies you are accustomed to working with aren't available, it can be worthwhile to program the AVR in C++. Constructors and destructors are functional and just the organizational advantages of using classes and object oriented programming may make C++ a great choice.

提交回复
热议问题