Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <unistd.h>
int gethostname(char *name, size_t namelen);
#define _OE_SOCKETS
#include <unistd.h>
int gethostname(char *name, int namelen);
Special behavior for C++: To use this function with C++, you must use the _XOPEN_SOURCE_EXTENDED 1 feature test macro.
If successful, gethostname() returns 0.