I am us ing MS visual studio 2010 for compiling the C source code. While compiling I am getting the problem with header file time.h.The problem is , I get the error
"undefined reference to the suseconds_t" and some other syntactical error on the structure.
But the the structure timeval is defined as follows.
I am passing this structure in the function named getTimeofDay(struct timeval *tv, struct timezone *tz) to get the elapse time. This function is defined
Once i change the DWORD with int long and time_t and suseconds_t with long , it compiles. Could you please let me know how can I get rid of this problem.
My operating system is Windows XP.
There is no such a type suseconds_t in Windows. So you must either change it (or the whole structure) to something that exists in Windows, or #define (or typedef) it.
The problem is all about timing behviour.My source file includes time.h, which defines the structure timeval. The definition of timeval in the time.h is:
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(16): error C2011: 'timeval' : 'struct' type redefinition
Hmm.. The strange thing is that in my VS2010 installation time.h file is in
\Microsoft Visual Studio 10.0\VC\include
and NOT in
\Microsoft Visual Studio 10.0\VC\include\sys
Also, it doesn't have your definition of timeval; it has:
Code:
/*
* Structure used in select() call, taken from the BSD file sys/time.h.
*/
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
Thanks for your reply. Actually I am newbie in MS visual studio. I have source files which i want to compile in MSVS. I may be missing some basic stuffs, so please let me know what are the stupids I am doing. I have been trying to solve it since few days, but not able to do.
It looks like some "cross-platform" source code wrtitten by a *nix-guy. suseconds_t is a *NIX (linux) specific type.
You have to add the right preprocessor definitions in the project properties in order to choose the right headers for Windows.
For example, probably HAVE_WINDOWS_H has to be defined.
May be others but without seeing all the project code / properties, none can even guess.
Besides.
Are you using VS Express Edition? If yes, have you installed the right SDK?
Last edited by ovidiucucu; June 28th, 2011 at 12:53 AM.
Bookmarks