Weiß jemand, was mit diesem Stück Code falsch ist? Ich kann nicht sehen, das Problem unter den vergleichbaren Fragen zu finden.Fehler: erwartete Deklaration Spezifizierer oder '...' vor String-Konstante
Der Code ist in C geschrieben, und ich bekomme diesen Fehler immer wieder. Ich mache -D SET_MIN_TEMP=5 -D Set_MAX_TEMP=30
an die gcc Kompilierung Zeile hinzufügen die ifndefs um sicherzustellen, dass falsch sein sollte ...
#ifndef CONFIG_H
#define CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
#ifndef RUN_AVG_LENGTH
#define RUN_AVG_LENGTH 5
#endif
#ifndef SET_MIN_TEMP
printf("please set SET_MIN_TEMP \n");
#endif
#ifndef SET_MAX_TEMP
printf("please set SET_MAX_TEMP \n");
#endif
typedef uint16_t sensor_id_t;
typedef uint16_t room_id_t;
typedef double sensor_value_t;
typedef time_t sensor_ts_t; // UTC timestamp as returned by time() - notice that the size of time_t is different on 32/64 bit machine
typedef struct {
sensor_id_t id;
sensor_value_t value;
sensor_ts_t ts;
} sensor_data_t;
typedef struct {
sensor_id_t sensor_id;
room_id_t room_id;
double running_avg[5];
sensor_ts_t timestamp;
} sensor_node_t;
#endif // CONFIG_H
'Set_MAX_TEMP'! =' SET_MAX_TEMP' weil C Fall empfindlich ist. – Barmar
Für welche Zeile erhalten Sie einen Fehler? Warum haben Sie 'printf()' Zeilen auf oberster Ebene so? – Barmar
Wenn Sie Fehler bei der Kompilierung verursachen möchten, wenn ein Makro nicht definiert ist, verwenden Sie '# error'. – Barmar