]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
build: Fix nss code snippet includes
authorTomas Bzatek <tbzatek@redhat.com>
Tue, 31 Jan 2023 22:27:53 +0000 (23:27 +0100)
committerTomas Bzatek <tbzatek@redhat.com>
Tue, 31 Jan 2023 22:27:53 +0000 (23:27 +0100)
With hardened distribution CFLAGS the meson code snippet wouldn't compile:

Compiler stderr:
  .build/meson-private/tmpy2z1t5q4/testfile.c: In function 'main':
  .build/meson-private/tmpy2z1t5q4/testfile.c:2:30: error: storage size of 'hints' isn't known
      2 |              struct addrinfo hints, *result;
        |                              ^~~~~
  .build/meson-private/tmpy2z1t5q4/testfile.c:3:21: warning: implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration]
      3 |              return getaddrinfo(argv[1], argv[2], &hints, &result);
        |                     ^~~~~~~~~~~

meson.build

index d389cbf062b9c3216c1931e386acf7160ef1e040..cf72d6d8b1ec3c299624f19c977ff2d7ff2be549 100644 (file)
@@ -199,7 +199,10 @@ conf.set10(
 conf.set(
     'HAVE_LIBNSS',
     cc.links(
-      '''int main(int argc, char **argv) {
+      '''#include <sys/types.h>
+         #include <sys/socket.h>
+         #include <netdb.h>
+         int main(int argc, char **argv) {
              struct addrinfo hints, *result;
              return getaddrinfo(argv[1], argv[2], &hints, &result);
       }