Fehler bei snprintf_P(.) Arduino ESP8266

Gast #4895672
Lesenswert?

Hallo zusammen,

ich beschäftige mich gerade mit dem ESP8266 in der Arduino Umgebung.

Als Basis schaue ich mir das Sonoff-Projekt von Arendts an:
https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino

Um den Quelltext besser zu verstehen, möchte ich mir zusätzliche Debug 
Meldungen generieren:
1
void setRelay(uint8_t power)
2
{
3
  snprintf_P(log, sizeof(log), PSTR("Test"));
4
  addLog(LOG_LEVEL_INFO, log);
5
  snprintf_P(log, sizeof(log), PSTR("Power: %d"), power);
6
  addLog(LOG_LEVEL_INFO, log);
7
.
8
.
9
.

Obwohl die Syntax vielfach, auch unter der Verwendung von sizeof(), in 
dem Quelltext verwendet wird, meckert der Compiler bei mir und ich sehe 
absolut nicht warum.
1
Arduino: 1.6.13 (Windows 7), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 1M (64K SPIFFS), ck, Disabled, None"
2

3
C:\Portable\arduino\arduino-1.6.13\portable\sketchbook\v3.9.11_Sonoff-Tasmota-master\Sonoff-Tasmota-master\sonoff\sonoff.ino: In function 'void setRelay(uint8_t)':
4

5
sonoff:751: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
6

7
   snprintf_P(log, sizeof(log), PSTR("Test"));
8

9
                             ^
10

11
sonoff:751: error: cannot convert 'double (*)(double)' to 'char*' for argument '1' to 'int snprintf_P(char*, size_t, const char*, ...)'
12

13
   snprintf_P(log, sizeof(log), PSTR("Test"));
14

15
                                            ^
16

17
sonoff:752: error: cannot convert 'double (*)(double)' to 'const char*' for argument '2' to 'void addLog(byte, const char*)'
18

19
   addLog(LOG_LEVEL_INFO, log);
20

21
                             ^
22

23
sonoff:753: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
24

25
   snprintf_P(log, sizeof(log), PSTR("Power: %d"), power);
26

27
                             ^
28

29
sonoff:753: error: cannot convert 'double (*)(double)' to 'char*' for argument '1' to 'int snprintf_P(char*, size_t, const char*, ...)'
30

31
   snprintf_P(log, sizeof(log), PSTR("Power: %d"), power);
32

33
                                                        ^
34

35
sonoff:754: error: cannot convert 'double (*)(double)' to 'const char*' for argument '2' to 'void addLog(byte, const char*)'
36

37
   addLog(LOG_LEVEL_INFO, log);
38

39
                             ^
40

41
exit status 1
42
ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
Gast #4895738
Lesenswert?

scheiße...log war gar nicht definiert. Ich dachte es wäre global 
definiert, aber es wird tatsächlich in jeder Funktion definiert, in der 
Log-Meldungen ausgegeben werden sollen: char log[LOGSZ];

Vielen Dank euch

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren