Hi guys,
There is a union in fib_prefix_t but without a name, and the use of the union
in 'add_port_range_adjacency' is shown below:
union {
ip46_address_t fp_addr;
struct {
mpls_label_t fp_label;
mpls_eos_bit_t fp_eos;
dpo_proto_t fp_payload_proto;
};
fib_prefix_t pfx =
{
.fp_proto = FIB_PROTOCOL_IP4,
.fp_len = length,
.fp_addr =
{
.ip4 = *address,
},
};
When we use the gcc(version 4.3.3). There is some error info:
/home/vpp/build-data/../src/vnet/ip/ip4_source_and_port_range_check.c: In
function 'add_port_range_adjacency':
/home/vpp/build-data/../src/vnet/ip/ip4_source_and_port_range_check.c:935:
error: unknown field 'fp_addr' specified in initializer
/home/vpp/build-data/../src/vnet/ip/ip4_source_and_port_range_check.c:935:
warning: braces around scalar initializer
/home/vpp/build-data/../src/vnet/ip/ip4_source_and_port_range_check.c:935:
warning: (near initialization for 'pfx.fp_proto')
/home/vpp/build-data/../src/vnet/ip/ip4_source_and_port_range_check.c:936:
error: field name not in record or union initializer
/home/vpp/build-data/../src/vnet/ip/ip4_source_and_port_range_check.c:936:
error: (near initialization for 'pfx.fp_proto')
/home/vpp/build-data/../src/vnet/ip/ip4_source_and_port_range_check.c:936:
error: incompatible types in initialization
We fix this problem by the method below,but it seems not a good method ,
because there are too many similar definitions in VPP.
Do you have any suggestion to solve it without updating the gcc version?
fib_prefix_t pfx;
memset(&pfx,0,sizeof(fib_prefix_t));
pfx.fp_proto = FIB_PROTOCOL_IP4;
pfx.fp_len = length;
pfx.fp_addr.ip4 = *address;
Thanks,
Xyxue