ECP-VeloC / AXL

Asynchronous Transfer Library
MIT License
2 stars 8 forks source link

warning: implicit declaration of function ‘fprintf’ #21

Closed tonyhutter closed 5 years ago

tonyhutter commented 5 years ago

Today both @CamStan and I hit a build error caused by https://github.com/ECP-VeloC/AXL/pull/20:

prefix/VELOC/deps/AXL/src/axl_async_bbapi.c:71:9: warning: implicit declaration of function ‘fprintf’ [-Wimplicit-function-declaration]
         fprintf(stderr, "Hostname too long\n");
         ^~~~~~~
prefix/VELOC/deps/AXL/src/axl_async_bbapi.c:71:9: warning: incompatible implicit declaration of built-in function ‘fprintf’
prefix/VELOC/deps/AXL/src/axl_async_bbapi.c:71:9: note: include ‘<stdio.h>’ or provide a declaration of ‘fprintf’
prefix/VELOC/deps/AXL/src/axl_async_bbapi.c:71:17: error: ‘stderr’ undeclared (first use in this function); did you mean ‘opterr’?
         fprintf(stderr, "Hostname too long\n");
                 ^~~~~~
                 Opterr
⋮
prefix/VELOC/deps/AXL/src/axl_async_bbapi.c: At top level:
prefix/VELOC/deps/AXL/src/axl_async_bbapi.c:131:8: error: unknown type name ‘BBTAG’
static BBTAG axl_get_unique_tag(void)
        ^~~~~
prefix/VELOC/deps/AXL/src/axl_async_bbapi.c: In function ‘axl_get_unique_tag’:
prefix/VELOC/deps/AXL/src/axl_async_bbapi.c:135:5: error: unknown type name ‘uint64_t’; did you mean ‘u_int64_t’?
     uint64_t timestamp;
     ^~~~~~~~
     u_int64_t

Strangely, I don't hit it when building with the IBM BB API:

$ make
Scanning dependencies of target axl_o
[  8%] Building C object src/CMakeFiles/axl_o.dir/axl_async_bbapi.c.o
[ 66%] Built target axl_o
Linking C shared library libaxl.so
[ 66%] Built target axl
Linking C static library libaxl.a
[ 66%] Built target axl-static
Linking C executable test_axl
[100%] Built target test_axl
[hutter2@butte5:build]$ make clean
[hutter2@butte5:build]$ make
[  8%] Building C object src/CMakeFiles/axl_o.dir/axl.c.o
[ 16%] Building C object src/CMakeFiles/axl_o.dir/axl_sync.c.o
[ 25%] Building C object src/CMakeFiles/axl_o.dir/axl_async_daemon.c.o
[ 33%] Building C object src/CMakeFiles/axl_o.dir/axl_async_datawarp.c.o
[ 41%] Building C object src/CMakeFiles/axl_o.dir/axl_async_bbapi.c.o
[ 50%] Building C object src/CMakeFiles/axl_o.dir/axl_err.c.o
[ 58%] Building C object src/CMakeFiles/axl_o.dir/axl_io.c.o
[ 66%] Building C object src/CMakeFiles/axl_o.dir/axl_util.c.o
[ 66%] Built target axl_o
Linking C shared library libaxl.so
[ 66%] Built target axl
Linking C static library libaxl.a
[ 66%] Built target axl-static
[ 75%] Building C object test/CMakeFiles/test_axl.dir/test_axl.c.o
[ 83%] Building C object test/CMakeFiles/test_axl.dir/test_axl_sync.c.o
[ 91%] Building C object test/CMakeFiles/test_axl.dir/test_axl_async_daemon.c.o
[100%] Building C object test/CMakeFiles/test_axl.dir/test_axl_async_ibmbb.c.o
Linking C executable test_axl
[100%] Built target test_axl

$ git show 
commit f8a3c31e3444435bab30e1a87abae09899b651fb
Author: Tony Hutter <hutter2@llnl.gov>
Date:   Tue Mar 5 13:07:15 2019 -0800

    Get IBM BB test working

    - Get IBM burst buffer test working.
    - Add command line arguments to test_axl.
    - More extensive verification of destination file after transfer.
    - Use the number at the end of the hostname for our "rank" that
      gets passed to BB_InitLibrary().
    - Use seconds + nanoseconds to create our unique BBTAG.
    - Misc cleanups

diff --git a/src/axl_async_bbapi.c b/src/axl_async_bb
CamStan commented 5 years ago

I was able to replicate that it doesn't hit the error when building with IBM BB API.

adammoody commented 5 years ago

Maybe bbapi.h includes the missing headers?

CamStan commented 5 years ago

Did a grep on those files:

./bbapi.h:#include "bbapi_types.h"
⋮
./bbapi_types.h:typedef unsigned long BBTAG;
./bbapi_types.h:#include "BBStatus.h"
⋮
./BBStatus.h:#include <stdio.h>
adammoody commented 5 years ago

It's probably good to #include directly in this file, since we use it.

We could also conditionally compile the unique_node_id() function within a #ifdef HAVE_BBAPI guard, since we only need to compile that function when using the BB.

adammoody commented 5 years ago

To be complete, let's also directly include headers in axl_async_bbapi.c for other symbols we use here like gethostname, strlen, isdigit, and atoi.

tonyhutter commented 5 years ago

Yea, I can reproduce the error in my VM locally and am including the headers. There's a few other fixes I'll need as well.

CamStan commented 5 years ago

Build was successful for me after #22.