struct timeval redeclared in network.h

Post Reply
SimonKagstrom
Posts: 4
Joined: Sat Mar 14, 2009 2:15 pm

struct timeval redeclared in network.h

Post by SimonKagstrom » Sat Mar 14, 2009 2:17 pm

Hi!

In the CVS trunk of libogc/wii, struct timeval is redeclared in network.h, which causes a compile error for me. I believe it should be removed. Patch below.

// Simon

Code: Select all

Index: gc/network.h
===================================================================
RCS file: /cvsroot/devkitpro/libogc/gc/network.h,v
retrieving revision 1.12
diff -u -r1.12 network.h
--- gc/network.h	23 May 2008 16:02:41 -0000	1.12
+++ gc/network.h	14 Mar 2009 13:13:47 -0000
@@ -157,11 +157,6 @@
 	u8 fd_bits [(FD_SETSIZE+7)/8];
   } fd_set;
 
-  struct timeval {
-    s32    tv_sec;         /* seconds */
-    s32    tv_usec;        /* and microseconds */
-  };
-
 #endif
 
 #ifndef TCP_NODELAY

WinterMute
Site Admin
Posts: 1859
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: struct timeval redeclared in network.h

Post by WinterMute » Mon Mar 16, 2009 9:57 pm

As noted in the other post, we moved to SVN.

Can you show some code where this struct causes a problem though. I suspect you're probably right but I'd need to confirm.
Help keep devkitPro toolchains free, Donate today

Personal Blog

SimonKagstrom
Posts: 4
Joined: Sat Mar 14, 2009 2:15 pm

Re: struct timeval redeclared in network.h

Post by SimonKagstrom » Tue Mar 17, 2009 7:18 am

Code: Select all

powerpc-gekko-g++ -MMD -MP -MF /home/ska/projects/wii/frodo-wii/trunk/build/Display.d -O3 -g -Wall -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float   -I/home/ska/projects/wii/frodo-wii/trunk/build -I/opt/devkitpro//libogc/include -U__unix -DHAVE_SDL -DPRECISE_CPU_CYCLES=1 -DPRECISE_CIA_CYCLES=1 -DPC_IS_POINTER=0 -DFRODO_SC -I/opt/devkitpro//SDL/include  -c /home/ska/projects/wii/frodo-wii/trunk/Src/Display.cpp -o Display.o
In file included from /home/ska/projects/wii/frodo-wii/trunk/Src/Network.h:5,
                 from /home/ska/projects/wii/frodo-wii/trunk/Src/C64.h:27,
                 from /home/ska/projects/wii/frodo-wii/trunk/Src/Display_SDL.h:22,
                 from /home/ska/projects/wii/frodo-wii/trunk/Src/Display.cpp:95:
/opt/devkitpro//libogc/include/network.h:160: error: redefinition of 'struct timeval'
/opt/devkitpro/devkitPPC/lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/sys/time.h:16: error: previous definition of 'struct timeval'
I'm including <sys/time.h> in a sysdeps.h file which gets included basically everywhere in my project. Since network.h also includes sys/time.h, I would think that it would hit this problem elsewhere as well but it doesn't. I think it's safe to remove the struct defintion though, and probably the same thing goes for FD_SET etc, which can also be found in other headers.

Oibaf
Posts: 34
Joined: Mon Jul 04, 2011 1:03 pm

Re: struct timeval redeclared in network.h

Post by Oibaf » Mon Jul 04, 2011 1:14 pm

I have the same problem.
The structure "timeval" is defined both in libogc (network.h)

struct timeval {
s32 tv_sec; /* seconds */
s32 tv_usec; /* and microseconds */
};

and in devkitpcc/newlib (sys/time.h)

#ifndef _WINSOCK_H
#define _TIMEVAL_DEFINED
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};

This causes an error in compiling a program using both the modules.
The structures are the same since both time_t and suseconds_t are long (s32 for WII).
The code below in libogc (network.h) can solve the conflict:

#ifndef _TIMEVAL_DEFINED
struct timeval {
s32 tv_sec; /* seconds */
s32 tv_usec; /* and microseconds */
};
#endif // TIMEVAL

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest