Skip to content

Using PSTR and PROGMEM string with template class causes section type conflict #3369

Closed
@sticilface

Description

@sticilface

Using latest git and arduino IDE.

I use PROGMEM strings and a debug define that places debug messages into progmem, however this does not seem to work when combined with templated classes.

The error is the same as this issue: #2078

i define my debug as

#define DEBUG(_1, ...) { TEST.printf_P( PSTR(_1) ,##__VA_ARGS__); }

and a const char as

const char testString[] PROGMEM = "Test String"; 

Individually they both compile. i.e. if the debug define is enabled but i do not use testString. it works, and vice versa. but if i use both

In file included from /Users/amelvin/Documents/Arduino/templatesketch/templatesketch.ino:2:0:
test.h:7: error: testString causes a section type conflict with __c
 const char testString[] PROGMEM = "Test String"; 
            ^
In file included from /Applications/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/Arduino.h:240:0,
                 from /var/folders/nv/8j3v5v0s18v7p4249kv8qbz80000gq/T/arduino_build_216642/sketch/templatesketch.ino.cpp:1:
/Applications/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/pgmspace.h:21:51: note: '__c' was declared here
 #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
                                                   ^
/var/folders/nv/8j3v5v0s18v7p4249kv8qbz80000gq/T/arduino_build_216642/sketch/test.h:11:41: note: in expansion of macro 'PSTR'
 #define DEBUG(_1, ...) { TEST.printf_P( PSTR(_1) ,##__VA_ARGS__); }
                                         ^
/var/folders/nv/8j3v5v0s18v7p4249kv8qbz80000gq/T/arduino_build_216642/sketch/test.hpp:5:3: note: in expansion of macro 'DEBUG'
   DEBUG("abc");
   ^
exit status 1
testString causes a section type conflict with __c

A full working example can be found here
https://gist.github.com/sticilface/9a6410978d7235a469c1e154c1c4c396

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions