This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: 1.5.24,XP: time.h + mrtd switch in gcc conflicting types


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]