Search code examples
cgccopenbsd

<resolv.h> on OpenBSD gives incomplete type errors


My ssl bindings for R compile on linux, osx, windows and solaris but on OpenBSD it fails when including resolv.h. Is this a bug in OpenBSD? Should I (not) include some other header first?

egcc -std=gnu99 -I/usr/local/lib/R/include -DNDEBUG -I/usr/include -I/usr/local/include    -fpic  -O2 -pipe  -c ssl.c -o ssl.o
In file included from ssl.c:14:0:
/usr/include/resolv.h:137:3: error: array type has incomplete element type
   nsaddr_list[MAXNS]; /* address of name server */
   ^
/usr/include/resolv.h:147:18: error: field 'addr' has incomplete type
   struct in_addr addr;
                  ^
/usr/include/resolv.h:164:19: error: field 'ina' has incomplete type
    struct in_addr ina;
                   ^
/usr/include/resolv.h:165:20: error: field 'in6a' has incomplete type
    struct in6_addr in6a;
                    ^
/usr/local/lib/R/etc/Makeconf:134: recipe for target 'ssl.o' failed
gmake: *** [ssl.o] Error 1

Solution

  • The correct answer was given in the comment:

    #include <netinet/in.h>
    #include <resolv.h>