Skip to content

Instantly share code, notes, and snippets.

@sticilface
Created June 23, 2017 07:14
Show Gist options
  • Save sticilface/9a6410978d7235a469c1e154c1c4c396 to your computer and use it in GitHub Desktop.
Save sticilface/9a6410978d7235a469c1e154c1c4c396 to your computer and use it in GitHub Desktop.
Error when using PROGMEM strings and DEBUG with PSTR() in template functions
#ifndef TEST_H
#define TEST_H
#define TEST Serial
const char testString[] PROGMEM = "Test String";
#if defined(TEST)
#define DEBUG(_1, ...) { TEST.printf_P( PSTR(_1) ,##__VA_ARGS__); }
#else
#define DEBUG(...) {}
#endif
template<typename T>
class testClass {
public:
void a();
};
#include "test.hpp"
#endif
template<typename T>
void testClass<T>::a() {
DEBUG("abc");
Serial.println(FPSTR(testString));
}
#include "test.h"
testClass<int> a;
void setup() {
// put your setup code here, to run once:
a.a();
}
void loop() {
// put your main code here, to run repeatedly:
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment