Skip to content

[AVR] error: reinterpret_cast from 'const __FlashStringHelper *' (aka 'const __attribute__((address_space(1))) char *') to 'const char *' is not allowed #60982

Closed as not planned
@KOLANICH

Description

@KOLANICH
//toolchain/hardware/tools/avr/avr/include/avr/pgmspace.h
#ifndef PGM_P
#define PGM_P const char *
// or #define PGM_P __attribute__((address_space(1))) const char * - the same issue
#endif

//toolchain/hardware/arduino/avr/cores/arduino/WString.h
using __FlashStringHelper = __attribute__((address_space(1))) char;

//toolchain/hardware/arduino/avr/cores/arduino/Print.cpp
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
error: reinterpret_cast from 'const __FlashStringHelper *' (aka 'const __attribute__((address_space(1))) char *') to 'const char *' is not allowed

Workaround:

PGM_P p = (PGM_P)(ifsh);

Related:
arduino/ArduinoCore-avr#524
arduino/ArduinoCore-API#184

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions