Created
June 23, 2017 07:14
-
-
Save sticilface/9a6410978d7235a469c1e154c1c4c396 to your computer and use it in GitHub Desktop.
Error when using PROGMEM strings and DEBUG with PSTR() in template functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
void testClass<T>::a() { | |
DEBUG("abc"); | |
Serial.println(FPSTR(testString)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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