I’ve moved over to a Zero so I don’t take down my server. This code replicates the problem seen on different platforms and produces the compile errors below (code follows). Moving the macro below the #include <BlynkSimpleEthernet2.h>
solves the problem, but that’s a band-aid. On larger projects this can cause problems if multiple libraries start having precedence requirements.
Macro_fail:29: error: variable or field 'BlynkWidgetWrite8' declared void
BLYNK_WRITE(V8){
^
Macro_fail:29: error: 'BlynkReq' was not declared in this scope
BLYNK_WRITE(V8){
^
Macro_fail:29: error: expected primary-expression before 'const'
BLYNK_WRITE(V8){
^
exit status 1
variable or field 'BlynkWidgetWrite8' declared void
--
The example code
#define RANDOM_MACRO(mode) int empty_function(void) { return (int) (mode); }
#include <SPI.h>
#include <Ethernet2.h>
RANDOM_MACRO(5); // CAUSES COMPILE ERROR IF IT'S HERE
#include <BlynkSimpleEthernet2.h>
// RANDOM_MACRO(5); // COMPILES IF ITS AFTER #include <BlynkSimpleEthernet2.h>
IPAddress ip(192,168,222, 120 );
const char auth[] = "authorization code";
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
static IPAddress myDns(8,8,8,8);
IPAddress subnet_mask(255, 255, 255, 0);
void setup() {
Blynk.begin(auth, "blynk-cloud.com", 8442, ip, myDns, mac);
}
void loop() {
Blynk.run();
}
BLYNK_WRITE(V8){
int pinValue = param.asInt(); // assigning incoming value from pin V2 to a variable
Serial.print("V* button value is: ");
Serial.println(pinValue);
}