可能重复:
常量变量在标头中不起作用
在我用来创建共享对象的头文件中,我有以下内容:
#ifndef LIB_HECA_DEF_H_
#define LIB_HECA_DEF_H_
struct dsm_config {
int auto_unmap;
int enable_copy_on_access;
};
enum { NO_AUTO_UNMAP, AUTO_UNMAP } unmap_flag;
enum { NO_ENABLE_COA, ENABLE_COA } coa_flag;
const struct dsm_config DEFAULT_DSM_CONFIG = { AUTO_UNMAP, NO_ENABLE_COA };
<more code ...>
#endif
当我编译时,我收到以下错误:
cc -g -Wall -pthread libheca.c dsm_init.c -DDEBUG master.c -o master
/tmp/cciBnGer.o:(.rodata+0x0): multiple definition of `DEFAULT_DSM_CONFIG'
/tmp/cckveWVO.o:(.rodata+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [master] Error 1
任何想法为什么?