Compiler error of EthernetInterface + GCC ARM
Information
Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.
Compiler error of EthernetInterface + GCC ARM
When you compile a exported project that conotains EthernetInterface by GCC ARM ver 5.2 (2015/4q) or later, following error occurs.
In file included from ./EthernetInterface/Socket/Socket.h:21:0, from ./EthernetInterface/Socket/TCPSocketConnection.h:22, from ./EthernetInterface/EthernetInterface.h:84, from main.cpp:2: ./EthernetInterface/lwip/include/lwip/sockets.h:311:8: error: redefinition of 's truct timeval' struct timeval { ^ In file included from c:\program files\gnu tools arm embedded\5.2 2015q4\arm-non e-eabi\include\sys\select.h:27:0, from c:\program files\gnu tools arm embedded\5.2 2015q4\arm-non e-eabi\include\sys\types.h:89, from c:\program files\gnu tools arm embedded\5.2 2015q4\arm-non e-eabi\include\stdio.h:48, from c:\program files\gnu tools arm embedded\5.2 2015q4\arm-non e-eabi\include\c++\5.2.1\cstdio:42, from ./mbed/platform.h:27, from ./mbed/mbed.h:21, from main.cpp:1: c:\program files\gnu tools arm embedded\5.2 2015q4\arm-none-eabi\include\sys\_ti meval.h:51:8: error: previous definition of 'struct timeval' struct timeval { ^ Makefile:60: recipe for target `main.o' failed make: *** [main.o] Error 1
The way to fix the error
following description is written in EthernetInterface\lwip\include\lwip\sockets.h(304).
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided * by your system, set this to 0 and include <sys/time.h> in cc.h */
According to this description, you can fix this error by modifing following 2 files.
EthernetInterface\lwip\include\lwip\sockets.h(307)
#define LWIP_TIMEVAL_PRIVATE 1 ↓ #define LWIP_TIMEVAL_PRIVATE 0
EthernetInterface\lwip-sys\arch\cc.h(35)
#include <stdint.h> ↓ #include <stdint.h> #include <sys/time.h>
cause
In GCC ARM ver.5.2, <sys/select.h> is added to the system include file.
"struct timeval" is defined in this file, and this causes duplicate definition.
Information
ここから日本語です。
EterhnetInterface + GCC ARM でコンパイルエラー
EthernetInterfaceをimportしたプロジェクトをGCC ARMでexportし、 GCC ARMのver.5.2以降(2015/4q以降)でコンパイルすると、以下のコンパイルエラーが出力されます。
In file included from ./EthernetInterface/Socket/Socket.h:21:0, from ./EthernetInterface/Socket/TCPSocketConnection.h:22, from ./EthernetInterface/EthernetInterface.h:84, from main.cpp:2: ./EthernetInterface/lwip/include/lwip/sockets.h:311:8: error: redefinition of 's truct timeval' struct timeval { ^ In file included from c:\program files\gnu tools arm embedded\5.2 2015q4\arm-non e-eabi\include\sys\select.h:27:0, from c:\program files\gnu tools arm embedded\5.2 2015q4\arm-non e-eabi\include\sys\types.h:89, from c:\program files\gnu tools arm embedded\5.2 2015q4\arm-non e-eabi\include\stdio.h:48, from c:\program files\gnu tools arm embedded\5.2 2015q4\arm-non e-eabi\include\c++\5.2.1\cstdio:42, from ./mbed/platform.h:27, from ./mbed/mbed.h:21, from main.cpp:1: c:\program files\gnu tools arm embedded\5.2 2015q4\arm-none-eabi\include\sys\_ti meval.h:51:8: error: previous definition of 'struct timeval' struct timeval { ^ Makefile:60: recipe for target `main.o' failed make: *** [main.o] Error 1
対応方法
EthernetInterface\lwip\include\lwip\sockets.h(304)に以下の記述があります。
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided * by your system, set this to 0 and include <sys/time.h> in cc.h */
この記述どおり、以下2箇所の変更を行うことで、エラーを回避できます。
EthernetInterface\lwip\include\lwip\sockets.h(307)
#define LWIP_TIMEVAL_PRIVATE 1 ↓ #define LWIP_TIMEVAL_PRIVATE 0
EthernetInterface\lwip-sys\arch\cc.h(35)
#include <stdint.h> ↓ #include <stdint.h> #include <sys/time.h>
原因
GCC ARM ver.5.2より、標準ライブラリのインクルードファイルに<sys/select.h>が追加されました。
この中でtimeval構造体を定義しており、lwip内で定義しているtimeval構造体と重複定義となってしまうようです。
1 comment on Compiler error of EthernetInterface + GCC ARM:
Please log in to post comments.
I met the same problem and it works for me. thanks.