- 3D-Druck Einstieg und Tipps         
Ergebnis 1 bis 4 von 4

Thema: ASURO-Bibliothek in C++ ?

  1. #1
    Erfahrener Benutzer Roboter Experte
    Registriert seit
    14.04.2007
    Ort
    Einhausen
    Alter
    68
    Beiträge
    697

    ASURO-Bibliothek in C++ ?

    Anzeige

    LiFePo4 Akku selber bauen - Video
    Die ASURO-Bibliothek ist ja in nettem C geschrieben und auch wirklich gut lesbar, wenn man die Kommentare entfernt. Da WinAVR auch einen C++-Compiler enthält, könnte man die ASURO-Bibliothek ebenfalls in C++ schreiben, also ohne diese hässlichen #define und Macros. Hat das schon jemand versucht oder darüber nachgedacht? Sicher nicht neu die Idee.

    Aus C:/WinAVR/doc/avr-libc/avr-libc-user-manual/FAQ.html#faq_cplusplus
    Can I use C++ on the AVR?
    Basically yes, C++ is supported (assuming your compiler has been configured and compiled to support it, of course). Source files ending in .cc, .cpp or .C will automatically cause the compiler frontend to invoke the C++ compiler. Alternatively, the C++ compiler could be explicitly called by the name avr-c++.

    However, there's currently no support for libstdc++, the standard support library needed for a complete C++ implementation. This imposes a number of restrictions on the C++ programs that can be compiled. Among them are:

    * Obviously, none of the C++ related standard functions, classes, and template classes are available.

    * The operators new and delete are not implemented, attempting to use them will cause the linker to complain about undefined external references. (This could perhaps be fixed.)

    * Some of the supplied include files are not C++ safe, i. e. they need to be wrapped into

    extern "C" { . . . }

    (This could certainly be fixed, too.)

    * Exceptions are not supported. Since exceptions are enabled by default in the C++ frontend, they explicitly need to be turned off using -fno-exceptions in the compiler options. Failing this, the linker will complain about an undefined external reference to __gxx_personality_sj0.

    Constructors and destructors are supported though, including global ones.

    When programming C++ in space- and runtime-sensitive environments like microcontrollers, extra care should be taken to avoid unwanted side effects of the C++ calling conventions like implied copy constructors that could be called upon function invocation etc. These things could easily add up into a considerable amount of time and program memory wasted. Thus, casual inspection of the generated assembler code (using the -S compiler option) seems to be warranted.

  2. #2
    Moderator Robotik Einstein Avatar von damaltor
    Registriert seit
    28.09.2006
    Ort
    Milda
    Alter
    37
    Beiträge
    4.063
    geht bestimmt... aber warum?

    im endeffekt kann man den asuro (und seine lib) in jeder beliebigen sprach4 programmieren, wenn man einen IntelHex-Compiler findet...
    Read... or die.
    ff.mud.de:7600
    Bild hier  

  3. #3
    Erfahrener Benutzer Roboter Experte
    Registriert seit
    14.04.2007
    Ort
    Einhausen
    Alter
    68
    Beiträge
    697
    Man könnte objektorientiert programmieren. Die Frage ist, ob es sich lohnt. Könnte nur jemand beantworten, der es wirklich versucht hat.

  4. #4
    Erfahrener Benutzer Roboter Genie
    Registriert seit
    21.10.2005
    Ort
    Erde
    Alter
    57
    Beiträge
    1.195
    Das größte Problem an der Sache ist, dass man die C++ Programme nicht vernünftig debuggen kann - oder hat das jemand mit Eclipse CDT und einem separaten Simulator zum laufen bekommen?

    new und delete kann man sich zur Not selbst schreiben (wenn man's denn braucht) und Exceptions sind bei dem kleinen RAM der AVRs sowieso nicht das Gelbe vom Ei.

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

LiFePO4 Speicher Test