这是我在尝试编译一些使用taucs(而不是我的代码)的代码时遇到的错误:
.../taucs/src/taucs.h:554: error: conflicting declaration ‘typedef struct taucs_ccs_matrix taucs_ccs_matrix’
.../taucs/src/taucs.h:554: error: ‘taucs_ccs_matrix’ has a previous declaration as ‘typedef struct taucs_ccs_matrix taucs_ccs_matrix’
Run Code Online (Sandbox Code Playgroud)
笏?它与自己相冲突?
在我捏自己之后,我创建了一个测试标题,并提出了一个相互冲突的定义,只是为了确保我对此是正确的:
在文件testit.h中:
#include "somethingelse.h"
typedef struct
{
int n;
} foobar;
Run Code Online (Sandbox Code Playgroud)
在somethingelse.h文件中:
typedef struct
{
int n;
} foobar;
Run Code Online (Sandbox Code Playgroud)
果然,我得到:
testit.h:6: error: conflicting declaration ‘typedef struct foobar foobar’
somethingelse.h:4: error: ‘foobar’ has a previous declaration as ‘typedef struct foobar foobar’
Run Code Online (Sandbox Code Playgroud)
或者如果我在testit.h中有这个:
typedef struct
{
int n;
} foobar;
typedef struct
{
int n;
} foobar;
testit.h:9: error: conflicting declaration ‘typedef struct foobar foobar’
testit.h:4: error: ‘foobar’ has a previous declaration as ‘typedef struct foobar foobar’
Run Code Online (Sandbox Code Playgroud)
行号始终不同 - 声明不能与自身冲突.我不明白.谁有人见过这个?
Har*_*lby 15
单个标头是否包含在多个源文件中?如果是这样,你需要将它包装在"include guard"中,如下所示:
#ifndef TAUCS_H
#define TAUCS_H
//Header stuff here
#endif //TAUCS_H
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21952 次 |
| 最近记录: |