bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

HOST_NAME_MAX


From: Simon Josefsson
Subject: HOST_NAME_MAX
Date: Wed, 01 Apr 2009 08:06:29 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.90 (gnu/linux)

POSIX requires this symbol, but MinGW doesn't appear to define it:

../../../../src/gss-0.1.1/lib/krb5/name.c:89: error: 'HOST_NAME_MAX' undeclared 
(first use in this function)

According to MSDN gethostname documentation:

http://msdn.microsoft.com/en-us/library/ms738527.aspx

"So if a buffer of 256 bytes is passed in the name parameter and the
namelen parameter is set to 256, the buffer size will always be
adequate."

Thus it seems we could define HOST_NAME_MAX to 256 on mingw?

One complication is that POSIX says the symbol should be defined in
limits.h.  Do we need a gnulib replacement header for limits.h to be
able to define HOST_NAME_MAX?

Placing it in the existing gnulib unistd.h replacement is another idea.
That requires that projects include that when they need it.  glibc
unistd.h does not define HOST_NAME_MAX.  So it doesn't seem like a good
solution.

Another solution may be to say that you should never use HOST_NAME_MAX
and provide a better solution.  Gnulib's xgethostname isn't generally
usable in a library because it uses the xalloc module which calls exit
on memory allocation failures.  Maybe define a new gethostname_safe
function that works like xgethostname but doesn't use xalloc?

/Simon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]