blynkkk / blynk-library

Blynk library for IoT boards. Works with Arduino, ESP32, ESP8266, Raspberry Pi, Particle, ARM Mbed, etc.
https://blynk.io
MIT License
3.83k stars 1.38k forks source link

ESP8266: ADC_MODE(ADC_VCC) incompatibility #399

Closed vshymanskyy closed 6 years ago

vshymanskyy commented 6 years ago
ADC_MODE(ADC_VCC);

#include <ESP8266WiFi.h>          // wifi
#include <BlynkSimpleEsp8266.h>   // blynk library

char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

void setup()
{
  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
}

BLYNK_WRITE(V10) {}

=>

sketch_feb17a:20: error: variable or field 'BlynkWidgetWrite10' declared void
 BLYNK_WRITE(V10) {}
                                                            ^
sketch_feb17a:20: error: 'BlynkReq' was not declared in this scope
 BLYNK_WRITE(V10) {}
                         ^
sketch_feb17a:20: error: expected primary-expression before 'const'
 BLYNK_WRITE(V10) {}
ClintonKeith commented 6 years ago

This problem applies to other platforms as well with any kind of macro

Example:

define RANDOM_MACRO(mode) int empty_function(void) { return (int) (mode); }

If you instantiate the macro above the include

include // blynk library

you get the compile error, but if it's below the include it doesn't.

This applies (in my case) to

include

vshymanskyy commented 6 years ago

Workaround available: https://community.blynk.cc/t/variable-or-field-blynkwidgetwrite100-declared-void/22046/24?u=vhymanskyy

pieman64 commented 6 years ago

@vshymanskyy I think we need more than a workaround. We need to know what the problem is.

vshymanskyy commented 6 years ago

@pieman64 welcome to investigate! ;) This one should be an interesting adventure!

pieman64 commented 6 years ago

I have, I checked out the two completely different sketches that fail to compile.

vshymanskyy commented 6 years ago

I was investigating it, and it looks like the compiler/toolchain issue. The workaround works, so I'm closing this.