Неверное применение 'sizeof' к неполному типу вопроса - PullRequest
0 голосов
/ 07 сентября 2018

Я получаю ошибку

invalid application of 'sizeof' to incomplete type 'TProgmemRGBGradientPalette_byte* const [] {aka const unsigned char* const []}'

В линии 46 https://pastebin.com/xhVEnqts.

Последняя строка ниже - строка 46:

#define FASTLED_ALLOW_INTERRUPTS 0
#include "FastLED.h"
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WebSocketsClient.h> //  https://github.com/kakopappa/sinric/wiki/How-to-add-dependency-libraries
#include <ArduinoJson.h> // https://github.com/kakopappa/sinric/wiki/How-to-add-dependency-libraries
#include <StreamString.h>

#define DATA_PIN    3
#define LED_TYPE    WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS    30       // Change this to reflect the number of LEDs you have
#define BRIGHTNESS  128       // Set Brightness here

CRGB leds[NUM_LEDS];

#define SECONDS_PER_PALETTE 15


ESP8266WiFiMulti WiFiMulti;
WebSocketsClient webSocket;
WiFiClient client;

#define MyApiKey "xxxx" // TODO: Change to your sinric API Key. Your API Key is displayed on sinric.com dashboard
#define MySSID "xxxxx" // TODO: Change to your Wifi network SSID
#define MyWifiPassword "xxxx" // TODO: Change to your Wifi network password

#define HEARTBEAT_INTERVAL 300000 // 5 Minutes

uint64_t heartbeatTimestamp = 0;
bool isConnected = false;

void setPowerStateOnServer(String deviceId, String value);
void setTargetTemperatureOnServer(String deviceId, String value, String scale);

extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
extern const uint8_t gGradientPaletteCount;

uint8_t gCurrentPaletteNumber = 0;

CRGBPalette16 gCurrentPalette( CRGB::Black);
CRGBPalette16 gTargetPalette( gGradientPalettes[0] );

const uint8_t gGradientPaletteCount =
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );

Ответы [ 2 ]

0 голосов
/ 07 сентября 2018

Тип массива является неполным типом, если его размер отсутствует, и sizeof нельзя применить к неполному типу.

Следующая строка означает, что определение gGradientPalettes присутствует в каком-то другом файле.

extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];

Компилятор не может найти это определение и поэтому жалуется на эту строку:

const uint8_t gGradientPaletteCount =
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
0 голосов
/ 07 сентября 2018

Внешняя переменная с неизвестным размером времени компиляции.Если вы не можете найти размер, глядя на код, компилятор тоже не будет

...