这是我在尝试编译一些使用 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’
笏?是不是和自己矛盾?
在我捏自己之后,我创建了一个测试标头并输入了一个冲突的定义,以确保我对此是正确的:
在文件 testit.h 中:
#include "somethingelse.h"
typedef struct
{
int n;
} foobar;
在文件 somethingelse.h 中:
typedef struct
{
int n;
} foobar;
果然,我得到:
testit.h:6: error: conflicting declaration ‘typedef struct foobar foobar’
somethingelse.h:4: error: ‘foobar’ has a previous declaration as ‘typedef struct foobar foobar’
或者如果我在 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’
行号总是不同的——声明不能与自身冲突。我不明白。有人见过这个吗?