8

I am trying to build my source using gcc 8.3.0

root@eqx-sjc-engine2-staging:/usr/local/src# gcc --version
gcc (Debian 8.3.0-2) 8.3.0
Copyright (C) 2018 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.

root@eqx-sjc-engine2-staging:/usr/local/src# 

I am getting the below error

libs/esl/fs_cli.c:1679:43: error: '%s' directive output may be truncated writing up to 1023 bytes into a region of size 1020 [-Werror=format-truncation=]
   snprintf(cmd_str, sizeof(cmd_str), "api %s\nconsole_execute: true\n\n", argv_command);    
libs/esl/fs_cli.c:1679:3: note: 'snprintf' output between 29 and 1052 bytes into a destination of size 1024
       snprintf(cmd_str, sizeof(cmd_str), "api %s\nconsole_execute: true\n\n", argv_command);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    make[2]: *** [Makefile:2693: fs_cli-fs_cli.o] Error 1
    make[2]: Leaving directory '/usr/local/src'
    make[1]: *** [Makefile:3395: all-recursive] Error 1
    make[1]: Leaving directory '/usr/local/src'
    make: *** [Makefile:1576: all] Error 2

I tried running the make like below

make -Wno-error=format-truncation

Still I see the same issue.

my linux version is

root@eqx-sjc-engine2-staging:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux buster/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

How to fix it?

4
  • 3
    Depending on the makefile, you probably need something like make CFLAGS="-Wno-error=format-truncation"
    – muru
    Commented Mar 29, 2019 at 9:19
  • I do not want to edit the make file, is there a way to do it only via the command line argument. Like the one I tried above make -Wno-error=format-truncation
    – Karthik
    Commented Mar 29, 2019 at 9:49
  • 1
    @Karthik, muru gave you the command line: make CFLAGS="-Wno-error=format-truncation". Commented Mar 29, 2019 at 10:16
  • 1
    @muru, your comment sounds like the answer here; would you mind providing it as such? Thank you!
    – Jeff Schaller
    Commented Mar 29, 2019 at 14:42

2 Answers 2

7

Depending on the makefile, you probably need something like:

make CFLAGS="-Wno-error=format-truncation"

The default Makefile rules, and most well-written Makefiles, should see CFLAGS for option arguments to the C compiler being used. Similarly, you can use CXXFLAGS for providing options to the C++ compiler, and LDFLAGS for the linker.

3
  • Also make CPPFLAGS="-Wno-error=your-error-code" for C++. Commented Oct 3, 2021 at 14:29
  • 1
    @ScroogeMcDuck CPPFLAGS would be for the C preprocessor. CXXFLAGS is for C++.
    – muru
    Commented Oct 3, 2021 at 15:37
  • you're right, typo Commented Oct 5, 2021 at 17:56
1
./configure --enable-fatal-warnings=no
1
  • This would turn off more warnings than necessary.
    – Kusalananda
    Commented Oct 10, 2019 at 6:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .