Skip to content

Portability: HOST_NAME_MAX is not everywhere #64

@jimklimov

Description

@jimklimov

Google shows this issue popping up in many other projects too. Not all systems follow the same set of standards, and/or need to define special macros to enable those. Alternately MAXHOSTNAMELEN can be used on some systems. Note that these can have different sizes (I've seen 64, 255 and 256 in different OS samples), so if the limit is used in protocol strings it can cause some fun...

  CXX      src/src_fty_info_selftest-fty_info_selftest.o
/tmp/FTY/.srcclone/SunOS-i86pc-czmq_3/fty-info/src/fty_info_server.cc:32:28: fatal error: bits/local_lim.h: No such file or directory
 #include <bits/local_lim.h>
                            ^
compilation terminated.
gmake[2]: *** [Makefile:1032: src/src_libfty_info_la-fty_info_server.lo] Error 1
../../../.srcclone/SunOS-i86pc-czmq_3/fty-info/src/ftyinfo.cc: In function 'ftyinfo_t* ftyinfo_new(topologyresolver_t*)':
../../../.srcclone/SunOS-i86pc-czmq_3/fty-info/src/ftyinfo.cc:157:39: error: 'HOST_NAME_MAX' was not declared in this scope
     char *hostname = (char *) malloc (HOST_NAME_MAX+1);
                                       ^
gmake[2]: *** [Makefile:1025: src/src_libfty_info_la-ftyinfo.lo] Error 1
gmake[2]: Target 'all-am' not remade because of errors.
gmake[2]: Leaving directory '/tmp/FTY/.build/SunOS-i86pc-czmq_3/fty-info'
gmake[1]: *** [Makefile:1174: all-recursive] Error 1
gmake[1]: Target 'all' not remade because of errors.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions