mnba / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

struct timeval in time.hpp and time.cpp conflict with the same name structure definition in windows.h when compile with bz2lib #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The bzlib.h in bzip2 lib reference the windows.h in WIN32 platform, and
windows.h contains a structure: timeval which conflict with the same name
struct from time module.

Suggestion:
Change the all "timeval" to "timeval_" in both time.hpp and time.cpp, this
method passed my test

Original issue reported on code.google.com by jason.mi...@gmail.com on 7 Jun 2010 at 10:15

GoogleCodeExporter commented 9 years ago
thanks! but can't we just use the windows.h version then for _MSC_VER? time.?pp 
are
not the only place where timeval is used, and I'd prefer to have as little 
special
casing as possible.. 

Original comment by mark.duf...@gmail.com on 7 Jun 2010 at 6:45

GoogleCodeExporter commented 9 years ago

Original comment by mark.duf...@gmail.com on 7 Jun 2010 at 6:45

GoogleCodeExporter commented 9 years ago
Yes, besides time module the datetime and socket module also use that 
structure. As we know, the libc header files in linux also has the same name 
structure, might be a potential problem when adding more modules if we don't 
change the name. 

Original comment by jason.mi...@gmail.com on 8 Jun 2010 at 1:56

GoogleCodeExporter commented 9 years ago
I'm not sure I understand - there are no problems under linux, exactly because 
we are using the builtin, so there are no conflicting versions. it looks like 
for _MSC_VER, we can just include windows.h, instead of defining our own struct.

Original comment by mark.duf...@gmail.com on 8 Jun 2010 at 6:54

GoogleCodeExporter commented 9 years ago
hhaha, got you. :) A small change is enough as below, passed my test

time.hpp:

#if defined( _MSC_VER )

   //struct timeval {
   //     long    tv_sec;         /* seconds */
   //     long    tv_usec;        /* and microseconds */
   //};
   #include <windows.h> // using the timeval struct definition in windows.h which is exactly the same with the above def

   #include <time.h>
   #include <sys/timeb.h>
#else
   #include <sys/time.h>
#endif

Original comment by jason.mi...@gmail.com on 9 Jun 2010 at 1:52

GoogleCodeExporter commented 9 years ago
committed! please verify..

Original comment by mark.duf...@gmail.com on 9 Jun 2010 at 11:06

GoogleCodeExporter commented 9 years ago
time module test passed

Original comment by jason.mi...@gmail.com on 13 Jun 2010 at 9:37

GoogleCodeExporter commented 9 years ago
thanks again! closing then..

Original comment by mark.duf...@gmail.com on 13 Jun 2010 at 4:03