#49 time_t and clock_t using wrong types



In time.h clock_t and time_t are set as following_
typedef unsigned long clock_t;
typedef unsigned long time_t;

According to OpenGroup, may they not be unsigned:
"time_t and clock_t shall be integer or real-floating types."

I would recommend a normal long int instead.


  • Henning Nielsen Lund

    • assigned_to: nobody --> obarthel
  • Olaf Barthel

    Olaf Barthel - 2008-11-06

    This is difficult. Scalar time intervals come out as unsigned 32 bit integers on AmigaOS, hence the current definition of clock_t and time_t in clib2. This follows precedents, such as the 'C' runtime libraries for Lattice 'C', SAS/C and Aztec 'C'.

    According to the C99 specifications, however, the requirements for the clock_t and time_t types are less restrictive. Range and precision of times representable in clock_t and time_t are implementation-defined (section 7.23.1).

    I think we should leave the definitions as they are, since clib2 only aspires to C99 level functionality and does not hope to represent much of POSIX ;-)

  • Olaf Barthel

    Olaf Barthel - 2010-08-20
    • status: open --> closed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks