https://godbolt.org/z/YK5PPvz7d
#include <stdio.h>
struct file_format_a_header
{
int i;
};
struct file_format_b_header
{
int i;
};
int main()
{
int type = 1;
size_t len = 0;
if (1 == type)
{
len = sizeof(struct file_format_a_header ); // sizeof file_format_a_header and file_format_b_header is SAME but they are different structures
}
else
{
len = sizeof(struct file_format_b_header );
}
printf("len = %zu\n", len);
return 0;
}
<source>: In function 'main':
<source>:18:8: error: this condition has identical branches [-Werror=duplicated-branches]
18 | if (1 == type)
| ^
cc1: all warnings being treated as errors
ASM generation compiler returned: 1
<source>: In function 'main':
<source>:18:8: error: this condition has identical branches [-Werror=duplicated-branches]
18 | if (1 == type)
| ^
cc1: all warnings being treated as errors
Execution build compiler returned: 1
GCC switches:
-std=gnu11
-Wall
-Werror
-Wextra
-Wduplicated-branches
Question> Is there a way that I can fix this GCC warning?