Skip to content

cout should support const char arrays from flash #43

@pischky

Description

@pischky

It should be possible to use Macro "F()" to store strings (const char*) from flash memory (PROGMEM) like Arduinio print/println does. This saves RAM.

cout << F("\r\nSystem halted!") << endl;

The Arduino library uses class __FlashStringHelper in macro F(). I have added (in "ostream")

template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
    operator<<(basic_ostream<charT,traits>& out, const __FlashStringHelper* c)

and

template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
    operator<<(basic_ostream<char,traits>& out, const __FlashStringHelper* c)

With code from Arduino library file Print.cpp. Have given it a short test and it works on Arduino UNO with current IDE / eclipse.

Will try to attach patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions