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.84k stars 1.39k forks source link

Cannot compile anymore with 0.6.5, works on 0.6.1 #505

Closed maxgerhardt closed 3 years ago

maxgerhardt commented 3 years ago

Blynk library version: 0.6.5 IDE: [Arduino/Energia/MBED Compiler/Platform.IO/Eclipse ...]: PlatformIO IDE version: Core 5.0.4b1 Board type: diecimilaatmega168 Additional modules:

Scenario, steps to reproduce

Compile a sketch that worked in the previous library version.

Expected Result

Successful compilation.

Actual Result

Compilation failure with

.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::asLongLong() const':
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h:77:56: error: 'atoll' was not declared in this scope
     long long   asLongLong() const  { return atoll(buff); }

among otherst (see below)

Compilation details

Use the platformio.ini

[env:diecimilaatmega168]
platform = atmelavr
board = diecimilaatmega168
framework = arduino
monitor_speed = 9600
lib_deps = blynkkk/Blynk@0.6.1

And code

#include <Arduino.h>

#define BLYNK_PRINT SwSerial

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX

#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "mytoken";

// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);

// You can send commands from Terminal to your hardware. Just use
// the same Virtual Pin as your Terminal Widget
BLYNK_WRITE(V1)
{

  // if you type "Marco" into Terminal Widget - it will respond: "Polo:"
  if (String("Marco") == param.asStr()) {
    terminal.println("You said: 'Marco'") ;
    terminal.println("I said: 'Polo'") ;
  } else {

    // Send it back
    terminal.print("You said:");
    terminal.write(param.getBuffer(), param.getLength());
    terminal.println();
  }

  // Ensure everything is sent
  terminal.flush();
}

void setup()
{
  // Debug console
  SwSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  // Clear the terminal content
  terminal.clear();

  // This will print Blynk Software version to the Terminal Widget when
  // your hardware gets connected to Blynk Server
  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.println(F("-------------"));
  terminal.println(F("Type 'Marco' and get a reply, or type"));
  terminal.println(F("anything else and get it printed back."));
  terminal.flush();
}

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

compilation works

RAM:   [=====     ]  49.9% (used 511 bytes from 1024 bytes)
Flash: [========  ]  76.5% (used 10960 bytes from 14336 bytes)
==================== [SUCCESS] Took 2.51 seconds ====================

now delete .pio\libdeps folder and change lib_deps declaration to

lib_deps = blynkkk/Blynk@0.6.5

and you encounter

In file included from .pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkApi.h:16:0,
                 from .pio\libdeps\diecimilaatmega168\Blynk\src/BlynkApiArduino.h:14,
                 from .pio\libdeps\diecimilaatmega168\Blynk\src/Adapters/BlynkSerial.h:18,
                 from .pio\libdeps\diecimilaatmega168\Blynk\src/BlynkSimpleStream.h:18,
                 from src\main.cpp:9:
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::iterator::asLongLong() const':
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h:38:59: error: 'atoll' was not declared in this scope
         long long   asLongLong() const  { return atoll(ptr); }
Compiling .pio\build\diecimilaatmega168\FrameworkArduino\Print.cpp.o
                                                           ^
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::asLongLong() const':
Indexing .pio\build\diecimilaatmega168\libFrameworkArduinoVariant.a
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h:77:56: error: 'atoll' was not declared in this scope
     long long   asLongLong() const  { return atoll(buff); }
                                                        ^
In file included from .pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkHandlers.h:15:0,
                 from .pio\libdeps\diecimilaatmega168\Blynk\src\utility\BlynkHandlers.cpp:11:
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::iterator::asLongLong() const':
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h:38:59: error: 'atoll' was not declared in this scope
         long long   asLongLong() const  { return atoll(ptr); }
                                                           ^
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::asLongLong() const':
.pio\libdeps\diecimilaatmega168\Blynk\src/Blynk/BlynkParam.h:77:56: error: 'atoll' was not declared in this scope
     long long   asLongLong() const  { return atoll(buff); }
                                                        ^
*** [.pio\build\diecimilaatmega168\lib149\Blynk\utility\BlynkHandlers.cpp.o] Error 1
*** [.pio\build\diecimilaatmega168\src\main.cpp.o] Error 1
===================== [FAILED] Took 1.32 seconds =====================
maxgerhardt commented 3 years ago

Actually this issue can be resolved. The offending code is

    long        asLong() const      { return atol(buff); }
#ifndef BLYNK_NO_LONGLONG
    long long   asLongLong() const  { return atoll(buff); }
#endif

and long long is a really bad idea on an 8-bit microcontroller, so if I add build_flags = -D BLYNK_NO_LONGLONG in the platformio.ini to disable the code, it compiles.

To prevent compilation failures on Atmel chips, this should be the default? Can be checked with #if defined(__AVR__) too.

vshymanskyy commented 3 years ago

Thanks for reporting! Yes, currently defining BLYNK_NO_LONGLONG is a proper solution. We will try to improve the auto-detection anyway!

vshymanskyy commented 3 years ago

Please update to 0.6.7 (should be available in PIO soon)

maxgerhardt commented 3 years ago

Confirmed works with just lib_deps = blynkkk/Blynk@0.6.7 and no build_flags. Also, the new version is now visible in https://platformio.org/lib/show/415/Blynk 😄