gcc 4.4.7 compile code failed with the error like 'igzip/huff_codes.c:54: error: unknown field ‘lit_len_table’ specified in initializer'
- Dominant language
- C
- Stars
- 1.1k
- Forks
- 346
- PR merge metrics
- No merged PRs in 30d
Description
I compile the source code with the gcc (GCC) 4.4.7 on centos6 failed, error message like this:
igzip/huff_codes.c:54: error: unknown field ‘lit_len_table’ specified in initializer
igzip/huff_codes.c:55: error: unknown field ‘code_and_extra’ specified in initializer
igzip/huff_codes.c:55: warning: missing braces around initializer
igzip/huff_codes.c:55: warning: (near initialization for ‘static_hufftables...dist_lit_table[0].’)
igzip/huff_codes.c:55: error: unknown field ‘length2’ specified in initializer
igzip/huff_codes.c:55: warning: excess elements in struct initializer
igzip/huff_codes.c:55: warning: (near initialization for ‘static_hufftables...dist_lit_table[0]’)
igzip/huff_codes.c:56: error: extra brace group at end of initializer
igzip/huff_codes.c:56: error: (near initialization for ‘static_hufftables.’)
igzip/huff_codes.c:56: error: extra brace group at end of initializer
then, I compile the source code with the gcc (GCC) 4.8.5 on centos7 and it's successful.
The problem code:
``` c
struct huff_code {
union {
struct {
uint32_t code_and_extra:24;
uint32_t length2:8;
};
struct {
uint16_t code;
uint8_t extra_bit_count;
uint8_t length;
};
uint32_t code_and_length;
};
};
struct hufftables_icf {
union {
struct {
struct huff_code dist_lit_table[288];
struct huff_code len_table[256];
};
struct {
struct huff_code dist_table[31];
struct huff_code lit_len_table[513];
};
};
};
static struct hufftables_icf static_hufftables = {
.lit_len_table = {
{{{.code_and_extra = 0x00c,.length2 = 0x8}}},
{{{.code_and_extra = 0x08c,.length2 = 0x8}}},
{{{.code_and_extra = 0x04c,.length2 = 0x8}}},
{{{.code_and_extra = 0x0cc,.length2 = 0x8}}},
{{{.code_and_extra = 0x02c,.length2 = 0x8}}},
..........skip......
```
How can I fix it that I compile failed with gcc (GCC) 4.4.7
Contributor guide
Assessment
This issue has not been assessed yet.