What do I have to do to get this to compile? aggregate 'tm timeinfo' has incompl

This is where I have declared struct tm, and where the compile error is located.
Copied ‘struct tm timeinfo;’ straight from the ESP simple time example.

So why won’t the pain in the ar$e compile???

void CClock::begin()
{
  configTime(10L * 60 * 60, 0, "0.au.pool.ntp.org", "1.au.pool.ntp.org", "2.au.pool.ntp.org");
  ********* struct tm timeinfo; ********
  if (!getLocalTime(&stime))
  {
    m_RTC.setDay(timeinfo.tm_wday);
    m_RTC.setDate(timeinfo.tm_mday);
    m_RTC.setMonth(timeinfo.tm_mon);
    m_RTC.setYear(timeinfo.tm_year % 1000);
    if ((tm_mon >= 4) && (tm_mon <= 9))
      m_RTC.setHour(timeinfo.tm_hour);
    else
      m_RTC.setHour(timeinfo.tm_hour + 1);
    m_RTC.setMinute(timeinfo.tm_min);
    m_RTC.setSecond(timeinfo.tm_sec);
    m_RTC.setClock();
  }
  m_RTC.set24h();
  m_RTC.start();
}

Found this buried in the ESP32 folder…so the struct exists and is properly declared.

#ifndef _CLOCKS_PER_SEC_
#define _CLOCKS_PER_SEC_ 1000
#endif

#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
#define CLK_TCK CLOCKS_PER_SEC

#include <sys/types.h>

_BEGIN_STD_C

struct tm
{
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_wday;
  int tm_yday;
  int tm_isdst;
#ifdef __TM_GMTOFF
  long __TM_GMTOFF;
#endif
#ifdef __TM_ZONE
  const char *__TM_ZONE;
#endif
};

All of the code, including file includes at the top.

#include <Arduino.h>
#include <WiFiUdp.h>
#include "time.h"
#include "Clock.h"
#include "debug.h"

const char* CClock::m_arrayDOW[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

CClock::CClock()
{
  m_nMode = DISPLAY_TIME;
  m_colorDivision = rgb_color(0, 0, 255);
  m_colorRim = rgb_color(255, 0, 0);
  m_colorHour = rgb_color(0, 255, 0);
  m_colorMinute = rgb_color(0, 255, 0);
  m_colorSecond = rgb_color(0, 255, 0);
  m_colorText = rgb_color(255, 255, 255);
}

void CClock::begin()
{
  configTime(10L * 60 * 60, 0, "0.au.pool.ntp.org", "1.au.pool.ntp.org", "2.au.pool.ntp.org");
  ********* struct tm timeinfo; ********
  if (!getLocalTime(&stime))
  {
    m_RTC.setDay(timeinfo.tm_wday);
    m_RTC.setDate(timeinfo.tm_mday);
    m_RTC.setMonth(timeinfo.tm_mon);
    m_RTC.setYear(timeinfo.tm_year % 1000);
    if ((tm_mon >= 4) && (tm_mon <= 9))
      m_RTC.setHour(timeinfo.tm_hour);
    else
      m_RTC.setHour(timeinfo.tm_hour + 1);
    m_RTC.setMinute(timeinfo.tm_min);
    m_RTC.setSecond(timeinfo.tm_sec);
    m_RTC.setClock();
  }
  m_RTC.set24h();
  m_RTC.start();
}

CClock::~CClock()
{
}

void CClock::setDateTime(const uint8_t nDOW, const uint8_t nDOM, const uint8_t nMon, const uint8_t nYear, const uint8_t nHr, const uint8_t nMin, const uint8_t nSec)
{
    m_RTC.switchTo24h();
    m_RTC.setHours(nHr);
    m_RTC.setMinutes(nMin);
    m_RTC.setSeconds(nSec);
    m_RTC.setYear(nYear);
    m_RTC.setMonth(nMon);
    m_RTC.setDate(nDOM);
    m_RTC.setDayOfWeek(nDOW);
    m_RTC.setClock();
    
}

void CClock::point(const uint8_t nLEDNum, const rgb_color colour) 
{
    if ((nLEDNum >= 0) && (nLEDNum < NUM_LEDS))
        m_arrayLEDColors[nLEDNum] = colour;
}

void CClock::line(const uint8_t nStartLEDNum, const uint8_t nLength, const rgb_color colour)
{
    uint8_t nI = 0, nEndLEDNum = nStartLEDNum + nLength;
    
    if ((nStartLEDNum >= 0) && (nStartLEDNum < NUM_LEDS) && (nEndLEDNum >= 0) && (nEndLEDNum < NUM_LEDS) && (nEndLEDNum > nStartLEDNum))
    {
        for (nI = nStartLEDNum; nI <= nEndLEDNum; nI++)
            m_arrayLEDColors[nI] = colour;
    }
}

void CClock::doDisplayRim(const uint16_t nAngleSec, const uint16_t nAngleRot)
{
    m_arrayLEDColors[MAX_LED] = m_colorRim;
}

void CClock::doDisplaySecondHand(const uint16_t nAngleSec, const uint16_t nAngleRot)
{
  /*
    if (nAngleRot == nAngleSec)
        line(2, NUM_LEDS - 3);
  */
}

void CClock::doDisplayMinuteHand(const uint16_t nAngleMin, const uint16_t nAngleRot)
{
  /*
    if (nAngleRot == nAngleMin)
        line(2, NUM_LEDS - 5);
    else if ((nAngleRot == (nAngleMin - 1)) || (nAngleRot == (nAngleMin + 1)))
        line(2, NUM_LEDS - 6);
    else if ((nAngleRot == (nAngleMin - 2)) || (nAngleRot == (nAngleMin + 2)))
        line(2, NUM_LEDS - 7);
  */
}

void CClock::doDisplayHourHand(const uint16_t nAngleHour, const uint16_t nAngleRot)
{
  /*
    if (nAngleRot == nAngleHour)
        line(2, NUM_LEDS - 7);
    else if ((nAngleRot == (nAngleHour - 1)) || (nAngleRot == (nAngleHour + 1)))
        line(2, NUM_LEDS - 8);
    else if ((nAngleRot == (nAngleHour - 2)) || (nAngleRot == (nAngleHour + 2)))
        line(2, NUM_LEDS - 9);
    else if ((nAngleRot == (nAngleHour - 3)) || (nAngleRot == (nAngleHour + 3)))
        line(2, NUM_LEDS - 10);
    else if ((nAngleRot == (nAngleHour - 4)) || (nAngleRot == (nAngleHour + 4)))
        line(2, NUM_LEDS - 11);
    else if ((nAngleRot == (nAngleHour - 5)) || (nAngleRot == (nAngleHour + 5)))
        line(2, NUM_LEDS - 12);
   */
}

void CClock::doDisplayDivision(const uint16_t nAngleRot)
{
    if ((nAngleRot % 30) == 0.0)
    {
        line(MAX_LED - 2, MAX_LED - 1, m_colorDivision);
    }
    else if ((nAngleRot % 60) == 0.0)
    {
        point(MAX_LED - 1, m_colorDivision);
    }
}

char* CClock::formatNum(const unsigned int nNum)
{
    static char strNum[3] = "\0\0";
    
    utoa(nNum, strNum, 10);
    if (strlen(strNum) == 1)
    {
        strNum[1] = strNum[0];
        strNum[0] = '0';
    }
    return strNum;
}

char* CClock::getFormattedTime(const bool bPadded, const bool bFromDateTime)
{
    static char strTime[12] = "\0\0\0\0\0\0\0\0\0\0\0";
    uint8_t nMaxLen = 0;
    
    m_RTC.switchTo24h();  
    m_RTC.readClock();

    if (bPadded)
        nMaxLen = 2;

    strcpy(strTime, formatNum(m_RTC.getHours()));
    strcat(strTime, ":");
    strcat(strTime, formatNum(m_RTC.getMinutes()));
    strcat(strTime, ":");
    strcat(strTime, formatNum(m_RTC.getSeconds()));

    return strTime;
}

char* CClock::getFormattedDateTime(const bool bPadded)
{
    static char strDateTime[26] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";

    strcpy(strDateTime, getFormattedDate(bPadded, true));
    strcat(strDateTime, " ");
    strcat(strDateTime, getFormattedTime(bPadded, true));

    return strDateTime;
}

char* CClock::getFormattedDate(const bool bPadded, const bool bFromDateTime)
{
    static char strDate[17] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
    
    m_RTC.switchTo24h();  
    m_RTC.readClock();

    strcpy(strDate, m_arrayDOW[m_RTC.getDayOfWeek()]);
    strcat(strDate, " ");
    strcat(strDate, formatNum(m_RTC.getDate()));
    strcat(strDate, "-"); 
    strcat(strDate, formatNum(m_RTC.getMonth()));
    strcat(strDate, "-");
    strcat(strDate, formatNum(m_RTC.getYear()));

    return strDate;
}

extern uint32_t nLastMicros, lunRotPeriod;

void CClock::doDisplay()
{
    m_RTC.switchTo24h();  
    m_RTC.readClock();

    static uint8_t nDisplayTimeCount = 1;
    uint32_t lunMicrosElapsed = micros() - nLastMicros;
    uint16_t nRotAngle = ((float)lunMicrosElapsed / lunRotPeriod) * 360,
       nAngleSec = ((float)m_RTC.getSeconds() / 60) * 360,
             nAngleMin = ((float)(m_RTC.getMinutes() / 60) * 360) + (((float)m_RTC.getSeconds() / 60) * 30),
             nAngleHour = ((float)(m_RTC.getHours() / 12) * 360) + (((float)m_RTC.getMinutes() / 60) * 30) + (((float)m_RTC.getSeconds() / 60) * 6);
    
    
    if (isDisplayTimeMode())
    {
      //debug.log(getFormattedTime(true));
    //debug.log("nLastMicros = ", false);
    //debug.log(nLastMicros);
     
        //doDisplayRim(nDisplayTimeCount, m_arrayClockFields[SECOND].m_nFieldVal);
        //doDisplayHourHand(nRotAngle, nAngleHour + (nAngleMin * 30) + (nAngleSec * 6));
        //doDisplayMinuteHand(nRotAngle, nAngleMin + (nAngleSec * 6));
        //doDisplaySecondHand(nRotAngle, nAngleSec);
        //doDisplayDivision(nRotAngle);
    }
/*
    else if (isDisplayDateTimeMode())
    {
        m_text = getFormattedDateTime();
        m_text.doDisplay(this, nRotAngle);
      debug.log(m_text);
    }
    else if (isDisplayDateMode())
    {
        m_text = getFormattedDate();
        m_text.doDisplay(this, nRotAngle);
      debug.log(m_text);
    }
*/
    m_LEDStrip.write(m_arrayLEDColors, NUM_LEDS);
}

Your exact error message, referring to the file and line number, seems to have vanished in the haze.

  struct tm timeinfo;
  if (!getLocalTime(&stime))
  {
    m_RTC.setDay(timeinfo.tm_wday);

Where, exactly, are the fields of the timeinfo instance supposed to have been valued?

PaulS:
Your exact error message, referring to the file and line number, seems to have vanished in the haze.

  ******* struct tm timeinfo; ********

if (!getLocalTime(&stime))
  {
    m_RTC.setDay(timeinfo.tm_wday);



Where, exactly, are the fields of the timeinfo instance supposed to have been valued?

Line of code that generates the compile error is marked with ********* in all code snippets

Not really sure what you mean by 'have been valued'. Do you mean assigned a value? I assume function getLocalTime(...) assigns the struct fields a value.

boylesg:
Line of code that generates the compile error is marked with ********* in all code snippets

OK, that's the line. How about the message?

Delta_G:
OK, that’s the line. How about the message?

C:\Users\Greg\AppData\Local\Temp\arduino_build_523878\sketch\Clock.cpp: In member function ‘void CClock::begin()’:

Clock.cpp:23: error: aggregate ‘tm timeinfo’ has incomplete type and cannot be defined

struct tm timeinfo;

^

Clock.cpp:30: error: ‘tm_mon’ was not declared in this scope

if ((tm_mon >= 4) && (tm_mon <= 9))

^

Clock.cpp:31: error: ‘class RealTimeClockDS1307’ has no member named ‘setHour’

m_RTC.setHour(timeinfo.tm_hour);

^

Clock.cpp:33: error: ‘class RealTimeClockDS1307’ has no member named ‘setHour’

m_RTC.setHour(timeinfo.tm_hour + 1);

^

Clock.cpp:34: error: ‘class RealTimeClockDS1307’ has no member named ‘setMinute’

m_RTC.setMinute(timeinfo.tm_min);

^

Clock.cpp:35: error: ‘class RealTimeClockDS1307’ has no member named ‘setSecond’

m_RTC.setSecond(timeinfo.tm_sec);

^

Bloody hell - don't know what the hell the problem is with the f'ing struct but the ESP32 people need to sort this out!

Because the time library for ESP32 is unusble in its present form!

I tried this and I am no better off!

 typedef struct structTM
  {
    int  tm_sec;
    int tm_min;
    int tm_hour;
    int tm_mday;
    int tm_mon;
    int tm_year;
    int tm_wday;
    int tm_yday;
    int tm_isdst;
    #ifdef __TM_GMTOFF
      long  __TM_GMTOFF;
    #endif
    #ifdef __TM_ZONE
      const char *__TM_ZONE;
    #endif
  } tm;
  tm timeinfo;
  if (!getLoc
alTime(&timeinfo))

What the hell does this mean????

Can't convert tm* to tm* - makes no sense to me!

C:\Users\Greg\AppData\Local\Temp\arduino_build_523878\sketch\Clock.cpp: In member function 'void CClock::begin()':

Clock.cpp:42: error: cannot convert 'tm* {aka CClock::begin()::structTM*}' to 'tm*' for argument '1' to 'bool getLocalTime(tm*, uint32_t)'

if (!getLocalTime(&timeinfo))

This is rediculous - I try and compile the ESP32 simple time example, that also uses struct tm, and I get these compile errors related to Wfi.h

In file included from C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFi.h:31:0,

from C:\Users\Greg\AppData\Local\Temp\arduino_modified_sketch_958847\SimpleTime.ino:1:

C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFiType.h:46:1: warning: 'typedef' was ignored in this declaration

} ;

^

In file included from C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFi.h:32:0,

from C:\Users\Greg\AppData\Local\Temp\arduino_modified_sketch_958847\SimpleTime.ino:1:

C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFiSTA.h:39:5: error: 'wl_status_t' does not name a type

wl_status_t begin(const char* ssid, const char passphrase = NULL, int32_t channel = 0, const uint8_t bssid = NULL, bool connect = true);

^

In file included from C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFi.h:32:0,

from C:\Users\Greg\AppData\Local\Temp\arduino_modified_sketch_958847\SimpleTime.ino:1:

C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFiSTA.h:40:5: error: 'wl_status_t' does not name a type

wl_status_t begin(char* ssid, char passphrase = NULL, int32_t channel = 0, const uint8_t bssid = NULL, bool connect = true);

^

C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFiSTA.h:41:5: error: 'wl_status_t' does not name a type

wl_status_t begin();

^

C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFiSTA.h:75:5: error: 'wl_status_t' does not name a type

wl_status_t status();

^

C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFiSTA.h:84:28: error: 'wl_status_t' has not been declared

static void _setStatus(wl_status_t status);

^

C:\Users\Greg\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src/WiFiSTA.h:86:12: error: 'wl_status_t' does not name a type

static wl_status_t _status;

^

C:\Users\Greg\AppData\Local\Temp\arduino_modified_sketch_958847\SimpleTime.ino: In function 'void setup()':

SimpleTime:27: error: 'class WiFiClass' has no member named 'begin'

WiFi.begin(ssid, password);

^

SimpleTime:28: error: 'class WiFiClass' has no member named 'status'

while (WiFi.status() != WL_CONNECTED) {

But wifi.h all compiles just fine in my PovClock sketch.

WTF is going on with ESP32 core!

Think I am just going to give ESP32 time library the ar$e and just write my own damn code!