This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Macro expansion problem with adding ethernet driver


Hello.  I have added CYGPKG_NET_LWIP and CYGPKG_IO_ETH_DRIVERS to my kernel build for at91sam7xek.  When I build, the compile complains as follows:
packages/net/lwip_tcpip/v2_0_91/src/ecos/lwip_ecos_init.cxx:345:51: macro "IP4_ADDR" requires 5 arguments, but only 2 given

This line in the .cxx file is as follows:
IP4_ADDR(&ipaddr, CYGDAT_LWIP_SLIP_DEV_ADDR_IP);

IP4_ADDR is defined in packages/net/lwip_tcpip/v2_0_91/include/lwip/ip_addr.h as:
#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = htonl(((u32_t)(a & 0xff) << 24) | ((u32_t)(b & 0xff) << 16) | \
                                                         ((u32_t)(c & 0xff) << 8) | (u32_t)(d & 0xff))

and CYGDAT_LWIP_SLIP_DEV_ADDR_IP is defined in the .ecc as:
192,168,1,222

I am using gcc version 3.4.4.  When I use the -E compiler option in order to see the output of the preprocessor, the macro does not know how to expand correctly since it believes that there are only 2 parameters and the macro is defined with 5 parameters.

However, if I simply try to expand (&ipaddr, CYGDAT_LWIP_SLIP_DEV_ADDR_IP) without the IP4_ADDR macro, then it correctly expands to 5 parameters.  Additionally, when I change the #define IP4_ADDR in ip_addr.h to an inline function, it does not complain.

My conclusion is that the compiler is not expanding macros as I would hope... basically it attempts to expand IP4_ADDR before an attempt to expand CYGDAT_LWIP_SLIP_DEV_ADDR_IP.  Has any one else experienced this problem?  I would prefer to change as little of the ecos code as possible.  Is there a solution to this problem that does not involve changing the macro to an inline function?

Thank you for your time,
- Mike

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]