An equivalent of INT_MAX for size_t?

This is a discussion on An equivalent of INT_MAX for size_t? within the C Programming forums, part of the General Programming Boards category; Is there an equivalent of the defines in limits.h (ie, INT_MIN and INT_MAX) for the other standard types, like time_t, ...

  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046

    An equivalent of INT_MAX for size_t?

    Is there an equivalent of the defines in limits.h (ie, INT_MIN and INT_MAX) for the other standard types, like time_t, size_t, ssize_t etc? If so, where? is it part of C89? One of my compilers has a SIZET_MAX but the other (older one) doesn't . . . . I'd guess it's part of C99.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The minimum and maximum values are defined in stdint.h in C99.

    [edit]
    SIZE_MAX is the maximum for size_t.
    [/edit]

    Quzah.
    Last edited by quzah; 09-21-2006 at 03:15 PM.
    Hope is the first step on the road to disappointment.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Okay. Is there anything wrong with using (size_t)-1 if SIZE_MAX [not SIZET_MAX -- oops] isn't defined?
    Code:
    #ifndef SIZE_MAX
        #define SIZE_MAX ((size_t)-1)
    #endif
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. string equivalent of sprintf()
    By e66n06 in forum C++ Programming
    Replies: 4
    Last Post: 08-16-2007, 03:30 PM
  2. Pointer equivalent to array notation
    By bekkilyn in forum C Programming
    Replies: 4
    Last Post: 12-06-2006, 07:22 PM
  3. C++ Equivalent JPEG Functions?
    By stickman in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2006, 10:50 AM
  4. Replies: 10
    Last Post: 08-17-2005, 11:17 PM
  5. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 10:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21