简体   繁体   English

我收到一个“错误:重新定义”符号,即使我之前在文件中使用了相同的语法,

[英]I am getting an "error: redefinition of" symbol, even though I have used the same syntax earlier in the file,

I am creating a function stub (for a function foo_print_stats()) for a unit test,and have written the following code:我正在为单元测试创​​建一个函数存根(用于函数 foo_print_stats()),并编写了以下代码:

static void my_foo_stats(foo_fs_t * const fsys) {
    return;
}
#undef foo_print_stats
#define foo_print_stats my_foo_stats

I keep getting the error "redefininiton of my_foo_stats".我不断收到错误“my_foo_stats 的重新定义”。 I have tried changing the name to something else, to no avail.我尝试将名称更改为其他名称,但无济于事。 The parameters for my_foo_stats are the exact same as those passed to foo_print_stats. my_foo_stats 的参数与传递给 foo_print_stats 的参数完全相同。 I am confused because I have used the exact same syntax many times int the same file and it has all worked.我很困惑,因为我在同一个文件中多次使用完全相同的语法,并且一切正常。

Realized that the file where the function was initially being defined was getting included below where I was trying to redefine it.意识到最初定义函数的文件被包含在我试图重新定义它的下面。 thanks to @Tom Karzes for advice感谢@Tom Karzes 的建议

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么会出现“将链接重新定义为另一种符号”错误? - Why am I getting the “redefinition of link as different kind of symbol” error? 为什么我在执行时收到“public_stream, = nullptr”错误? 即使我已成功使用“fopen_s”读取文件? - Why am I getting a 'public_stream ! = nullptr' error on execution, even though I have successfully used 'fopen_s' to read a file? 为什么即使我定义了我正在使用的命令,也会得到对另一个文件的未定义引用? - Why am I getting an undefined reference to another file, even though I define the command I am using? 我已经使用结构返回多个值。但是尽管程序运行我没有得到任何结果 - I have used structure to return multiple value.But I am not getting any result though the program runs remove() 返回文件未找到错误(errno = 2),当我之前使用相同的文件字符串打开文件时 - remove() returning file not found error (errno = 2), when i used the same file string to open the file earlier 即使我洗了副牌,序列号/卡也一样 - Same sequence/same card even though i have shuffled the deck 为什么即使没有错误也没有得到想要的输出? - Why am I not getting the desired output even though no errors? 即使我在同一目录中有 txt 文件,文件指针在 C 中也不起作用 - File Pointer is not working in C even though i have the txt file in the same directory 隐含的函数声明,即使我已经包含该文件? - implicit declaration of function even though i have included the file? 即使一切似乎都正确,我还是收到了编译错误 - I'm getting compilation error even though everything seems to be right
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM