[ovs-dev] [PATCH] types: New macros ETH_ADDR_C and ETH_ADDR64_C.

Guoshuai Li ligs at dtdream.com
Thu Nov 30 11:15:00 UTC 2017


I also have this problem in centos.

I try it, remove "-std=gnu99" for gcc is worked.

[root at vNetCI ~]# gcc lgs.c
[root at vNetCI ~]#
[root at vNetCI ~]# gcc -std=gnu99 lgs.c
lgs.c:9:15: error: initializer element is not constant
      = (struct eth_addr) { { .ea =  { 0x00, 0x23, 0x20, 0x00, 0x00, 
0x01 } } };

this is my code:

struct eth_addr {
     union {
         char ea[6];
         int be16[3];
     };
};
static const struct eth_addr eth_addr_bfd
     = (struct eth_addr) { { .ea =  { 0x00, 0x23, 0x20, 0x00, 0x00, 0x01 
} } };

> Hi Ben,
>
> I faced following error while compiling OVS master on Ubuntu. I am not sure, if I am missing some compiler directive.
>
> ./include/openvswitch/types.h:173:41: error: initializer element is not constant
>   #define ETH_ADDR_C(A,B,C,D,E,F) (struct eth_addr) \
>                                           ^
> lib/packets.h:179:7: note: in expansion of macro 'ETH_ADDR_C'
>       = ETH_ADDR_C(ff,ff,ff,ff,ff,ff);
>         ^
>
> By removing the typecast from types.h file worked.
>
> --old--
> #define ETH_ADDR_C(A,B,C,D,E,F) (struct eth_addr) \
>       { { .ea = { 0x##A, 0x##B, 0x##C, 0x##D, 0x##E, 0x##F } } }
>
> --new--
> #define ETH_ADDR_C(A,B,C,D,E,F) \
>       { { .ea = { 0x##A, 0x##B, 0x##C, 0x##D, 0x##E, 0x##F } } }
>
> Warm Regards,
> Vishal
>
> -----Original Message-----
> From: ovs-dev-bounces at openvswitch.org [mailto:ovs-dev-bounces at openvswitch.org] On Behalf Of Ben Pfaff
> Sent: Thursday, November 30, 2017 2:59 AM
> To: Mark Michelson <mmichels at redhat.com>
> Cc: dev at openvswitch.org
> Subject: Re: [ovs-dev] [PATCH] types: New macros ETH_ADDR_C and ETH_ADDR64_C.
>
> On Wed, Nov 29, 2017 at 08:30:07PM +0000, Mark Michelson wrote:
>> On Tue, Nov 28, 2017 at 5:33 PM Ben Pfaff <blp at ovn.org> wrote:
>>
>>> These macros expand to constants of type struct eth_addr and struct
>>> eth_addr64, respectively, and make it more convenient to initialize
>>> or assign to an Ethernet address object.
>>>
>>> Signed-off-by: Ben Pfaff <blp at ovn.org>
>>>
>> Acked-by: Mark Michelson <mmichels at redhat.com>
> Thanks, applied to master.
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev



More information about the dev mailing list