X-Spam-Check-By: sourceware.org Message-ID: <4452D307.114E412F@dessent.net> Date: Fri, 28 Apr 2006 19:44:23 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Compiling with gettimeofday References: <20060429022227 DOT 15207 DOT qmail AT web35715 DOT mail DOT mud DOT yahoo DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com TV JOE wrote: > gcc -I/usr/include/mingw -I/usr/include/mingw/sys GoCart_v04.c -lm Stop right there. You should *never* do this. This is like filling a gasoline car's tank with diesel -- it will not work and it will cause breakage. Mingw is a completely separate environment from Cygwin, you can't just go mixing bits and pieces of each. They use radically different C runtimes. If you want to use mingw, you need to use -mno-cygwin. The include paths will be adjusted accordingly. This is quite a red herring though, because there's no need to use mingw to call gettimeofday(). Also, -lm is never needed with Cygwin and does nothing. > // Function to read system time. Only used for testing execution speed. > long int gettime(void) > { > struct timeval ltim; > > gettimeofday(<im, NULL); > return (((long int)ltim.tv_sec)*((long int)(1000000))+((long > int)ltim.tv_usec)); > } > > My includes at the top of the > source code are as below. > > // Inclusions > #include > #include > #include > #include > #include > > I've tried replacing time.h with unistd.h or including > sys/time.h after time.h. Any advice is welcome. Rather than guesswork, why not look it up? This is all standard stuff. It's defined by POSIX in the SUSv3. . Struct timeval is defined in sys/time.h. Your testcase works fine as follows: $ cat gettimeofday.c #include long int gettime(void) { struct timeval ltim; gettimeofday(<im, NULL); return (((long int)ltim.tv_sec)*((long int)(1000000))+((long int)ltim.tv_usec)); } $ gcc -Wall -c gettimeofday.c # no errors Remove that mingw include stuff, include sys/time.h, and you should be fine. If you run into problems, enable -Wall and read the relevant docs for each function that you call. Don't try to just throw random headers into the top of your file until it works. And don't post fragments of files, post standalone test cases that can be compiled. If you only post snippets of a file then we have no idea if the part you redacted contains the error. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/