Re: limits.h

From: Bob Harris (nospam.News.Bob_at_remove.Smith-Harris.us)
Date: 07/31/05

  • Next message: Bill Vermillion: "Re: USR1 is not working correctly."
    Date: Sat, 30 Jul 2005 23:27:24 GMT
    
    

    In article <ejalbert-72DFBF.22243629072005@localhost>,
     Eric Albert <ejalbert@cs.stanford.edu> wrote:

    > In article <42eaee0c$0$18637$14726298@news.sunsite.dk>,
    > Madhusudan Singh <spammers-go-here@spam.invalid> wrote:
    >
    > > Bob Harris wrote:
    > >
    > > > In article <42eae790$0$18648$14726298@news.sunsite.dk>,
    > > > Madhusudan Singh <spammers-go-here@spam.invalid> wrote:
    > > >
    > > >> Bob Harris wrote:
    > > >>
    > > >> > In article <42eacac6$0$18647$14726298@news.sunsite.dk>,
    > > >> > Madhusudan Singh <spammers-go-here@spam.invalid> wrote:
    > > >> >
    > > >> >> Hi
    > > >> >> I have a library that works on Linux and Solaris systems, and
    > > >> >> I now wish to
    > > >> >> port it to Mac OSX. A prospective user tried to compile it and found
    > > >> >> that PIPE_BUF is not defined. This is defined in limits.h. I have the
    > > >> >> following preprocessor directives :
    > > >> >>
    > > >> >> #ifdef __linux__
    > > >> >> #include<linux/limits.h>
    > > >> >> #endif
    > > >> >>
    > > >> >> #ifdef __sun__
    > > >> >> #include<limits.h>
    > > >> >> #endif
    > > >> >>
    > > >> >> How do I add a section for Mac / BSD ?
    > > >> >
    > > >> > From
    > > >> > man cpp
    > > >> >
    > > >> > do the following to see all the predefined MACROs
    > > >> >
    > > >> > touch foo.h; cpp -dM foo.h
    > > >> >
    > > >> > I tend to use __APPLE__ and sometimes and it with __POWERPC__ if the
    > > >> > code might be CPU sensitive.
    > > >> >
    > > >> > Bob Harris
    > > >>
    > > >> Thanks for the response.
    > > >>
    > > >> So, is limits.h accessed as #include<limits.h> or as
    > > >> #include<some_directory/limits.h> ? (On linux, one needs to specify
    > > >> linux/limits.h).
    > > >>
    > > >> I ask this because I do not have a Mac to test this on.
    > > >
    > > > #include <limits.h>
    > > >
    > > > By the way, this is the X/Open standard location for limits.h. Of
    > > > course that doesn't mean everyone agrees with X/Open :-)
    > > >
    > > > So I think you could change your code to do something like
    > > >
    > > > #if defined(__linux__)
    > > > # include <linux/limits.h>
    > > > #else
    > > > # include <limits.h>
    > > > #endif
    > > >
    > > > I am fairly sure that Tru64 UNIX and HP-UX both follow the X/Open
    > > > standard. And since Mac OS X is FreeBSD based, it is a good guess that
    > > > most BSD derived UNIX implementation will also have limits.h in
    > > > /usr/include/limits.h as well.
    > > >
    > > > So I think you can avoid special casing Sun and Mac, and just special
    > > > case Linux.
    > > >
    > > > Bob Harris
    > >
    > > Is PIPE_BUF even defined on Mac ?
    >
    > PIPE_BUF is indirectly defined in <limits.h> on Mac OS X 10.4. I'd
    > suggest taking Bob's advice and #includ'ing <limits.h>. In fact, I'd
    > suggest just using that header everywhere, since POSIX defines PIPE_BUF
    > as being in limits.h.
    >
    > -Eric

    what Eric said. /usr/include/limits.h does a #include of
    <sys/syslimits.h> which contains PIPE_BUF.

                                            Bob Harris


  • Next message: Bill Vermillion: "Re: USR1 is not working correctly."