Closed johnsonjh closed 2 weeks ago
I'll probably do the "Detect if GCC (or Clang) needs -std=c99
" addition in another PR though, that way those really old gcc versions build fine with just make
.
Edit: PR #111
Hi!
Yes, it is best to simply remove the flag. I do like compiling with pedantic flags, to detect possible errors.
@dmsc
Check out direnv - we use this on other projects I work on.
You can make a “.envrc” file which contains export CFLAGS="-whatever"
or other variables and it gets set automatically, and when you are working in that directory only, so you can have much stricter flags when developing.
(I did have to change my aliases for git clean
-ing to do git clean -fdx -e .envrc
so as to not blow away the file, if adding it to the .gitignore)
Did not knew direnv. Here what we use is to include a local.mk
file from the main makefile, this also allows to include custom variables. By using -include local.mk
, make ignores the error if the file does not exists.
Using
-pedantic-errors
is causing problems on some old compilers on the oldest but still supported Linux distributions, because it implies-pedantic
and strict ISO compliance old older but still supported Linux distributions, for example, on Ubuntu 14.04. It's also breaking the build on various other platforms. Sorry I didn't notice this earlier.Currently, gcc 4.4 with glibc 2.19, on Ubuntu 14.04 LTS (still supported through 2026), running
make
now fails with:and
env CFLAGS="-std=c99 -O3" make
now fails with:... and because of that flag, even setting
-std=gnu99
(or later) can't get around the errors:I can get around this, but it's going to need explicitly setting feature macros (and in a rather complicated way) for it to not cause problems on all the various platforms (Solaris, AIX, etc.) where that flag really changes the compilers behavior by also implying
-pedantic
and disallowing the use of any extensions.It is also going to require some source code changes for strict ISO compliance because as noted above you can't use unnamed structs/unions in strict ISO C99 modes.
So, the following patch fixes everything while still using
-pedantic-errors
, but it's a bit ugly:@dmsc I could clean that up a little bit more but I don’t like it.
So, I'll propose that you just remove the
-pedantic-errors
flag, for simplicity.That way
env CFLAGS="-std=gnu99 -O3" make
would be sufficent for building on such a configuration, without any of the above patching being needed.