【发布时间】:2021-10-19 12:02:33
【问题描述】:
示例代码 (t987.c):
void *NAME();
void *NAME(void *, int, unsigned);
调用:
$ gcc t987.c -c -DNAME=memset1
<nothing>
$ gcc t987.c -c -DNAME=memset
<command-line>: error: conflicting types for ‘memset’; have ‘void *(void *, int, unsigned int)’
t987.c:2:7: note: in expansion of macro ‘NAME’
2 | void *NAME(void *, int, unsigned);
| ^~~~
<command-line>: note: previous declaration of ‘memset’ with type ‘void *(void *, int, long unsigned int)’
t987.c:1:7: note: in expansion of macro ‘NAME’
1 | void *NAME();
# clang: the same behavior
问题:为什么函数名很重要?
【问题讨论】:
标签: c gcc compiler-errors clang diagnostics