This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

code computer studio (全局常量)编译问题



我在一个.h文件里面使用const定义了一个常量

const unsigned char MAX_temp = 50;

并且在下面的数组初始化语句里面使用了它

unsigned int GET_TEMP_value[MAX_temp] = {0};

然后编译器给出了这样的提示

Description Resource Path Location Type
#2170-D use of a const variable in a constant expression is nonstandard in C user_GLOBAL_VARIABLE.h /TEST5 line 23 C/C++ Problem

而当我试图使用类似于

#define MAX_ADC 20

或者类似于

#ifndef MAX_temp
#define MAX_temp 20
#endif

这样的定义时,

如果不包含这个.h文件,编译器会报错,提示找不到定义

Description Resource Path Location Type
#20 identifier "MAX_temp" is undefined user_init.c /TEST5 line 66 C/C++ Problem

而如果包含了这个文件,编译器会将这个.h文件里面所有剩下的变量都报错(重复定义错误);

请问各位,这个问题应该如何解决呢?