错误:字符串常量之前的预期声明说明符或’…’
有人知道这段代码有什么问题吗? 我无法在类似的问题中找到问题。
代码是用C语言编写的,我不断收到此错误。 我将-D SET_MIN_TEMP=5 -D Set_MAX_TEMP=30
到gcc编译行,以确保ifndefs应为false …
#ifndef CONFIG_H #define CONFIG_H #include #include #include #include #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
您不能在函数外部使用函数调用( printf
)。 如果要在编译时报告错误,你应该看一下#error
…
看到这里