#9 Can't build on Mac --- mising define

All versions
Portability (1)
David Jameson

Downloaded to my Mac, ./configure worked fine. But compilation failed with the error

../libmail/libmail_intl.h:49: error: ‘HOST_NAME_MAX’ undeclared here (not in a function)

Looking around, it turns out that HOST_NAME_MAX is not defined on the Mac platform. Instead there is something called _POSIX_HOST_NAME_MAX

Apparently this can be added to the configure process but I regret I don't know enough about that process to do it myself.


  • Actually, this is the right way to determine the maxium allowed size of a HOSTNAME. I 'll try to submit a patch till this weekend. It should be fixed in 0.3 version.

    • milestone: --> All versions
    • labels: 1167111 --> Portability
    • status: open --> open-accepted
  • My fault again. HOST_NAME_MAX is the proper way of determining maximum hostname length. I 'm Mac-illiterate but after some search it appears that you 're using a version of MacOS which defined MAXHOSTNAMELEN through <sys/param.h>. However, this isn't proper POSIX and libmail is currently more close to POSIX and I cannot support this through a release or a patch.

    (See STANDARDS section of http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/sethostname.3.html\)

    As a workaround you can try changing HOST_NAME_MAX occurences in libmail_intrl.h and libmail.c with MAXHOSTNAMELEN and include <sys/param.h>

    Hope this helps

  • David Jameson
    David Jameson

    I don't understand --- what I found was _POSIX_HOST_NAME_MAX. For example: see the results of the following grep

    DHJMacPro:/usr/include $ grep HOST_NAME_MAX *
    limits.h:#define _POSIX_HOST_NAME_MAX 255

    The term POSIX is part of the name, seems to me that makes it legitimate POSIX (grin)

    I'm running the very latest version of Mac OS X, by the way.

  • David Jameson
    David Jameson

    By the way, I just read that STANDARDS article to which you referred me and it clearly indicates that MAXHOSTNAMELEN was on older systems

    From the article
    The gethostname() function conforms to IEEE Std 1003.1-2001 (``POSIX.1''). Callers should be aware
    that {HOST_NAME_MAX} may be variable or infinite, but is guaranteed to be no less than
    {_POSIX_HOST_NAME_MAX}. On older systems, this limit was defined in the non-standard header
    <sys/param.h> as MAXHOSTNAMELEN, and counted the terminating null. The sethostname() function and the
    error returns for gethostname() are not standardized.

  • As far as I know POSIX requires this to be defined it with HOST_NAME_MAX. It 's not that simple to include something which seems to fit and make it work, 'POSIX' in the macro name seems legitimate for you, the first '_' doesn't seem legitimate to me though. MAXHOSTNAMELEN is defined in your mac?

  • David Jameson
    David Jameson

    My Fedora 9 Linux server also has it as shown in the following result for the same grep query

    posix1_lim.h:#define _POSIX_HOST_NAME_MAX 255

  • David Jameson
    David Jameson

    Also, please take a look at the POSIX reference on this


    which also refers to _POSIX_HOST_NAME_MAX and indicates that HOST_NAME_MAX is often not defined.

    In particular, all of the posix related symbols start with an underscore.

  • This is different, POSIX-compliant should define this macro, this doesn't imply that developers should directly refer to this macro. Maybe the correct way was through sysconf() after all, I 'll check it out. Please note however that my main concern is to run to Linux and BSD systems (as project info states), so it might take some time.

  • David Jameson
    David Jameson

    Mac OS X is derived from BSD (grin)

    In any case, I realize I can just modify the files myself, or add a -D to gcc....my main purpose for adding the info here was so that others who run into the same problem will be able to get more useful information without having to repeat my problems.

  • Jorge Vega
    Jorge Vega

    THe problem continues in 0.3 version for MAC leopard (PowerPC) and Snow Leopard (Intel) versions of th operating System. The exact error message is:
    make all-recursive
    Making all in man
    make[2]: Nothing to be done for `all'.
    Making all in libmail
    /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -D_GNU_SOURCE -Wall -Wunused -Wstrict-prototypes -O2 -MT imap4.lo -MD -MP -MF .deps/imap4.Tpo -c -o imap4.lo imap4.c
    libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -D_GNU_SOURCE -Wall -Wunused -Wstrict-prototypes -O2 -MT imap4.lo -MD -MP -MF .deps/imap4.Tpo -c imap4.c -fno-common -DPIC -o .libs/imap4.o
    In file included from ../libmail/libmail.h:36,
    from imap4.c:28:
    ../libmail/libmail_intl.h:49: error: ‘HOST_NAME_MAX’ undeclared here (not in a function)
    make[2]: *** [imap4.lo] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2