KarypisLab/GKlib

error: format '%lld' expects argument of type 'long long int *', but argument 4 has type 'ssize_t *' {aka 'long int *'}

dbl001 opened this issue · 2 comments

I'm trying to build GKlib on Big Sur OS X 11.4
% xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
(base) davidlaxer@x86_64-apple-darwin13 GKlib % xcrun --show-sdk-version
11.3
% /opt/local/bin/gcc --version
gcc (MacPorts gcc11 11.1.0_2) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make config

rm -rf build/Darwin-x86_64
mkdir -p build/Darwin-x86_64
cd build/Darwin-x86_64 && cmake /Users/davidlaxer/GKlib -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_INSTALL_PREFIX=~/local -DCMAKE_C_COMPILER=gcc
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 11.1.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/local/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for execinfo.h
-- Looking for execinfo.h - found
-- Looking for getline
-- Looking for getline - found
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/davidlaxer/GKlib/build/Darwin-x86_64
(base) davidlaxer@x86_64-apple-darwin13 GKlib % make
make -C build/Darwin-x86_64 all
/opt/local/bin/cmake -S/Users/davidlaxer/GKlib -B/Users/davidlaxer/GKlib/build/Darwin-x86_64 --check-build-system CMakeFiles/Makefile.cmake 0
/opt/local/bin/cmake -E cmake_progress_start /Users/davidlaxer/GKlib/build/Darwin-x86_64/CMakeFiles /Users/davidlaxer/GKlib/build/Darwin-x86_64//CMakeFiles/progress.marks
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/Makefile2 all
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/GKlib.dir/build.make CMakeFiles/GKlib.dir/depend
cd /Users/davidlaxer/GKlib/build/Darwin-x86_64 && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /Users/davidlaxer/GKlib /Users/davidlaxer/GKlib /Users/davidlaxer/GKlib/build/Darwin-x86_64 /Users/davidlaxer/GKlib/build/Darwin-x86_64 /Users/davidlaxer/GKlib/build/Darwin-x86_64/CMakeFiles/GKlib.dir/DependInfo.cmake --color=
Scanning dependencies of target GKlib
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/GKlib.dir/build.make CMakeFiles/GKlib.dir/build
...
 Building C object CMakeFiles/GKlib.dir/graph.c.o
/opt/local/bin/gcc  -I/Users/davidlaxer/GKlib/. -I/Users/davidlaxer/GKlib/test -DLINUX -D_FILE_OFFSET_BITS=64 -std=c99 -fno-strict-aliasing -march=native -fPIC -Werror -Wall -pedantic -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label -DNDEBUG -DNDEBUG2 -DHAVE_EXECINFO_H -DHAVE_GETLINE -O3 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -o CMakeFiles/GKlib.dir/graph.c.o -c /Users/davidlaxer/GKlib/graph.c
/Users/davidlaxer/GKlib/graph.c: In function 'gk_graph_Read':
/Users/davidlaxer/GKlib/graph.c:297:26: error: format '%lld' expects argument of type 'long long int *', but argument 3 has type 'ssize_t *' {aka 'long int *'} [-Werror=format=]
  297 |         if (fscanf(fpin, "%"SCNd64" %"SCNd64, &i, &i) != 2)
      |                          ^~~                  ~~
      |                                               |
      |                                               ssize_t * {aka long int *
In file included from /Users/davidlaxer/GKlib/./gk_arch.h:43,
                 from /Users/davidlaxer/GKlib/./GKlib.h:23,
                 from /Users/davidlaxer/GKlib/graph.c:10:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/inttypes.h:157:53: note: format string is defined here
  157 | #  define SCNd64        __SCN_64_LENGTH_MODIFIER__ "d"
/Users/davidlaxer/GKlib/graph.c:297:26: error: format '%lld' expects argument of type 'long long int *', but argument 4 has type 'ssize_t *' {aka 'long int *'} [-Werror=format=]
  297 |         if (fscanf(fpin, "%"SCNd64" %"SCNd64, &i, &i) != 2)
      |                          ^~~                      ~~
      |                                                   |
      |                                                   ssize_t * {aka long int *}
In file included from /Users/davidlaxer/GKlib/./gk_arch.h:43,
                 from /Users/davidlaxer/GKlib/./GKlib.h:23,
                 from /Users/davidlaxer/GKlib/graph.c:10:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/inttypes.h:157:53: note: format string is defined here
  157 | #  define SCNd64        __SCN_64_LENGTH_MODIFIER__ "d"
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/GKlib.dir/graph.c.o] Error 1
make[2]: *** [CMakeFiles/GKlib.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

I fixed this in my clone of repo as:

    if (fscanf(fpin, "%ld"SCNd64" %ld"SCNd64, &i, &i) != 2)

Somebody need to put this fix in the main repo.

Thanks. I fixed it by using the correct "%zd" modifier.