X-Spam-Check-By: sourceware.org From: "Dave Korn" To: References: Subject: RE: 1.5.24,XP: time.h + mrtd switch in gcc conflicting types Date: Fri, 27 Apr 2007 14:41:43 +0100 Message-ID: <02a401c788d1$caa9da60$2e08a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id l3RDgknk019954 On 27 April 2007 14:20, Angel Robert Lynas wrote: > Cygwin version 1.5.24-2, gcc version 3.4.4 > Windows XP > > Hi all. There seems to be an issue with "time.h" under some circumstances > with a new Cygwin version. Using a simple test program ( called t.c): > > #include > main() {} > > The problem arises when compilation is attempted with the -mrtd switch, Cygwin doesn't support randomly breaking the calling conventions. > the following errors arising: #1. Pilot error. > In file included from t.c:1: > /usr/include/time.h:150: error: conflicting types for 'clock_getres' 146 /* Clocks, P1003.1b-1993, p. 263 */ 147 148 int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp)); 149 int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp)); 150 int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res)); 151 > /usr/include/cygwin/time.h:20: error: previous declaration of > 'clock_getres' was here 17 18 int nanosleep (const struct timespec *, struct timespec *); 19 int clock_setres (clockid_t, struct timespec *); 20 int clock_getres (clockid_t, struct timespec *); 21 _EXFUN amounts to "extern _cdecl". Those definitions would normally agree if you hadn't changed the standard calling convention away from cdecl by using -mrtd. As such, this is a handy error message, as it tells you that if you /did/ compile your code that way, you would get stack corruption when both caller *and* callee think they are supposed to pop the stack args after a function call, resulting in overpopping and random SEGVs. Let me demonstrate: /artimi $ cat test.c struct timespec { }; typedef unsigned int clockid_t; extern int __cdecl clock_getres (clockid_t clock_id, struct timespec *res); int clock_getres (clockid_t, struct timespec *); @_______. . ( /"\ ||--||(___) '" '"'---' /artimi $ gcc -c test.c -o test.o -W -Wall @_______. . ( /"\ ||--||(___) '" '"'---' /artimi $ gcc -c test.c -o test.o -W -Wall -mrtd test.c:7: error: conflicting types for 'clock_getres' test.c:5: error: previous declaration of 'clock_getres' was here test.c:7: error: conflicting types for 'clock_getres' test.c:5: error: previous declaration of 'clock_getres' was here cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/