当前位置: 技术问答>linux和unix
C多文件编程的问题
来源: 互联网 发布时间:2016-09-27
本文导语: 在Ubuntu 9.10下面用make编译之后提示这样的错误: operate_file.c:15: error: conflicting types for ‘FileSize’ operate_file.h:7: note: previous declaration of ‘FileSize’ was here operate_file.c:21: error: conflicting types for ‘UpdataEndBuf’ o...
在Ubuntu 9.10下面用make编译之后提示这样的错误:
operate_file.c:15: error: conflicting types for ‘FileSize’
operate_file.h:7: note: previous declaration of ‘FileSize’ was here
operate_file.c:21: error: conflicting types for ‘UpdataEndBuf’
operate_file.h:8: note: previous declaration of ‘UpdataEndBuf’ was here
operate_file.c:73: error: conflicting types for ‘WriteConfig’
operate_file.h:9: note: previous declaration of ‘WriteConfig’ was here
operate_file.c:172: error: conflicting types for ‘ReadConfig’
operate_file.h:10: note: previous declaration of ‘ReadConfig’ was here
其中operate_file.h的内容如下:
#ifndef _OPERATE_FILE_H_
#define _OPERATE_FILE_H_
void FileSize(const char* file, int* size);
int UpdataEndBuf(char* buf,const char* key,const char* value);
int WriteConfig(const char* section,const char* key,const char* value,const char* file);
int ReadConfig(const char* section,const char* key,int *value,const char* file);
#endif
而operate_file.c里面只是对operate_file.h里面声明的四个函数进行实现。可以确认operate_file.c中的函数实现无语法错误。但是编译之后出现这种提示,不知道是什么原因。请各位指导一下。谢谢!
operate_file.c:15: error: conflicting types for ‘FileSize’
operate_file.h:7: note: previous declaration of ‘FileSize’ was here
operate_file.c:21: error: conflicting types for ‘UpdataEndBuf’
operate_file.h:8: note: previous declaration of ‘UpdataEndBuf’ was here
operate_file.c:73: error: conflicting types for ‘WriteConfig’
operate_file.h:9: note: previous declaration of ‘WriteConfig’ was here
operate_file.c:172: error: conflicting types for ‘ReadConfig’
operate_file.h:10: note: previous declaration of ‘ReadConfig’ was here
其中operate_file.h的内容如下:
#ifndef _OPERATE_FILE_H_
#define _OPERATE_FILE_H_
void FileSize(const char* file, int* size);
int UpdataEndBuf(char* buf,const char* key,const char* value);
int WriteConfig(const char* section,const char* key,const char* value,const char* file);
int ReadConfig(const char* section,const char* key,int *value,const char* file);
#endif
而operate_file.c里面只是对operate_file.h里面声明的四个函数进行实现。可以确认operate_file.c中的函数实现无语法错误。但是编译之后出现这种提示,不知道是什么原因。请各位指导一下。谢谢!
|
.h里面有const,而.c里面没有,导致不一致了。
.c:
void FileSize(char *file,int* size)
int UpdataEndBuf(char* end_buf,char* key,char* value)
int WriteConfig(char* section, char* key,char* value,char* file)
int ReadConfig(char* section,char* key,int* value,char* file)
.h:
void FileSize(const char* file, int* size);
int UpdataEndBuf(char* buf,const char* key,const char* value);
int WriteConfig(const char* section,const char* key,const char* value,const char* file);
int ReadConfig(const char* section,const char* key,int *value,const char* file);
|
void FileSize(char *file,int* size)
int UpdataEndBuf(char* end_buf,char* key,char* value)
int WriteConfig(char* section, char* key,char* value,char* file)
int ReadConfig(char* section,char* key,int* value,char* file)
void FileSize(const char* file, int* size);
int UpdataEndBuf(char* buf,const char* key,const char* value);
int WriteConfig(const char* section,const char* key,const char* value,const char* file);
int ReadConfig(const char* section,const char* key,int *value,const char* file);
int UpdataEndBuf(char* end_buf,char* key,char* value)
int WriteConfig(char* section, char* key,char* value,char* file)
int ReadConfig(char* section,char* key,int* value,char* file)
void FileSize(const char* file, int* size);
int UpdataEndBuf(char* buf,const char* key,const char* value);
int WriteConfig(const char* section,const char* key,const char* value,const char* file);
int ReadConfig(const char* section,const char* key,int *value,const char* file);
|
顶