https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117198
Bug ID: 117198
Summary: Why are there differences using -Wredundant-decls, is
bug or not?
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: hanwei62 at huawei dot com
Target Milestone: ---
there is a warning,and the code is, link:https://godbolt.org/z/1Ko7T4eso
```
#include <stdio.h>
int udk_exit_test()
{
printf("in udk_exit_test\n");
return 1;
}
int udk_exit_module1(void) __attribute__((weak, alias("udk_exit_test")));
int udk_exit_module1(void);
```
<source>:10:5: warning: redundant redeclaration of 'udk_exit_module1'
[-Wredundant-decls]
10 | int udk_exit_module1(void);
| ^~~~~~~~~~~~~~~~
<source>:8:5: note: previous definition of 'udk_exit_module1' with type
'int(void)'
8 | int udk_exit_module1(void) __attribute__((weak,
alias("udk_exit_test")));
| ^~~~~~~~~~~~~~~~
however, if I using by Macro, there is no warning
test.h:
```
#define udk_module_exit(exitfn) \
int udk_exit_module(void) __attribute__((weak, alias(#exitfn)))
int udk_exit_module(void);
```
test.c
```
#include <stdio.h>
#include "test.h"
int udk_exit_test()
{
printf("in udk_exit_test\n");
return 1;
}
udk_module_exit(udk_exit_test);
int main()
{
udk_exit_module();
return 0;
}
```
gcc test.c -Wredundant-decls