[DragonFlyBSD - Bug #2982] (Closed) Failed compile due to fetch.h and MAXHOSTNAMELEN

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Fri Jun 3 16:34:21 PDT 2022

Issue #2982 has been updated by tuxillo.

Status changed from New to Closed
Assignee set to tuxillo

Just include @sys/param.h@ before including fetch.h, as you yourself mentioned :)
Closing this one!

Bug #2982: Failed compile due to fetch.h and MAXHOSTNAMELEN

* Author: noloader
* Status: Closed
* Priority: Normal
* Assignee: tuxillo
* Target version: 6.4
* Start date: 2017-02-19
I'm trying to build pkgin for DragonFly. The compile is failing due to fetch.h and MAXHOSTNAMELEN (http://github.com/NetBSDfr/pkgin/issues/74):

$ make
gcc  -O -pipe    -std=gnu99  -c main.c
In file included from pkgin.h:45:0,
                 from main.c:33:
/usr/include/fetch.h:44:14: error: 'MAXHOSTNAMELEN' undeclared here (not in a function)
  char   host[MAXHOSTNAMELEN+1];
/usr/include/fetch.h:59:14: error: 'PATH_MAX' undeclared here (not in a function)
  char   name[PATH_MAX];


Looking at /usr/include/fetch.h, it does not include a header which defines MAXHOSTNAMELEN; and it does not define MAXHOSTNAMELEN itself:

$ cat fetch.h


#define _LIBFETCH_VER "libfetch/2.0"

#define URL_SCHEMELEN 16
#define URL_USERLEN 256
#define URL_PWDLEN 256

struct url {
        char             scheme[URL_SCHEMELEN+1];
        char             user[URL_USERLEN+1];
        char             pwd[URL_PWDLEN+1];
        char             host[MAXHOSTNAMELEN+1];
        int              port;
        char            *doc;
        off_t            offset;
        size_t           length;
        time_t           ims_time;


MAXHOSTNAMELEN is defined to 256 is a couple of other header files, but those headers are not picked up in fetch.h.

Looking at gethostname(3) (http://man.openbsd.org/gethostname.3), I can't tell if fetch.h is supposed to include <unistd.h> or <sys/param.h>. I'm guessing <unistd.h> would be a good choice.

You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account

More information about the Bugs mailing list