delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/04/27/09:42:58

X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
References: <op DOT trf1zpx63j2v8a AT scm-pc-633 DOT tees DOT ac DOT uk>
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
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <op.trf1zpx63j2v8a@scm-pc-633.tees.ac.uk>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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 <time.h>
> 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/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019