C/C++ Question help needed

Siam

Active Member
Licensed User
Longtime User
Hello,

i m a beginner in the c language but i will learn ;)

i have a problem with the following code:

the cpp file
B4X:
#include "B4RDefines.h"
#include <ESP8266WiFi.h>
#include <TimeLib.h>
#include <EasyNTPClient.h>
namespace B4R {
WiFiUDP udp;
  void B4RESP8266TimeTools::initialize(B4RString* ntpserver, int timezone) {
      lc =  new (backend) EasyNTPClient(udp, "fritz.box", 0);
    return;
  }
.....

and the h file:
B4X:
#pragma once
#include "B4RDefines.h"
#include <TimeLib.h>
#include <EasyNTPClient.h>
//~version: 1.33
namespace B4R {
     
    //~shortname: ESPTimetools
    class B4RESP8266TimeTools {
  private:
      uint8_t backend[sizeof(EasyNTPClient)];
        public:
    //~hide
            EasyNTPClient* lc;

      void initialize(B4RString* ntpserver, int timezone);
.......

if i compile it so it works fine

but if i change:

lc = new (backend) EasyNTPClient(udp, "fritz.box", 0);

to

lc = new (backend) EasyNTPClient(udp, ntpserver, timezone);

i will get the folowing errormessage:

B4X:
C:\Users\Andy\Desktop\b4r\LEDDIS~1\Objects\bin\sketch\rESP8266TimeTools.cpp: In member function 'void B4R::B4RESP8266TimeTools::initialize(B4R::B4RString*, int)':
rESP8266TimeTools.cpp:8: error: no matching function for call to 'EasyNTPClient::EasyNTPClient(WiFiUDP&, B4R::B4RString*&, int)'
    lc =  new (backend) EasyNTPClient(udp, ntpserver, 0);
                                                       ^
C:\Users\Andy\Desktop\b4r\LEDDIS~1\Objects\bin\sketch\rESP8266TimeTools.cpp:8:55: note: candidates are:
In file included from C:\Users\Andy\Desktop\b4r\LEDDIS~1\Objects\bin\sketch\rESP8266TimeTools.h:4:0,
                 from C:\Users\Andy\Desktop\b4r\LEDDIS~1\Objects\bin\sketch\B4RDefines.h:31,
                 from C:\Users\Andy\Desktop\b4r\LEDDIS~1\Objects\bin\sketch\rESP8266TimeTools.cpp:1:
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:25:5: note: EasyNTPClient::EasyNTPClient(UDP&, const char*, int)
     EasyNTPClient(UDP& udp, const char* serverPool, int offset);
     ^
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:25:5: note:   no known conversion for argument 2 from 'B4R::B4RString*' to 'const char*'
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:24:5: note: EasyNTPClient::EasyNTPClient(UDP&, const char*)
     EasyNTPClient(UDP& udp, const char* serverPool);
     ^
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:24:5: note:   candidate expects 2 arguments, 3 provided
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:23:5: note: EasyNTPClient::EasyNTPClient(UDP&)
     EasyNTPClient(UDP &udp);
     ^
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:23:5: note:   candidate expects 1 argument, 3 provided
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:20:7: note: constexpr EasyNTPClient::EasyNTPClient(const EasyNTPClient&)
 class EasyNTPClient
       ^
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:20:7: note:   candidate expects 1 argument, 3 provided
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:20:7: note: constexpr EasyNTPClient::EasyNTPClient(EasyNTPClient&&)
C:\Users\Andy\Documents\Arduino\libraries\EasyNTPClient-master\src/EasyNTPClient.h:20:7: note:   candidate expects 1 argument, 3 provided

i use this library : https://github.com/aharshac/EasyNTPClient


i don't know what went wrong there :(
can somebody please explain me what i do wrong here?

and is it possible to send data from this lib to the serial console ?
serial.prinln seems not to work.

regards

Andy
 
Last edited:

rboeck

Well-Known Member
Licensed User
Longtime User
I had a ghostwriter, my 17 year old son. My own c++ knowledge is completly null.
 
Top