builder: pass `-std=gnu99` to the C backend under linux (#12236)

pull/12241/head
Lance Fredrickson 2021-10-20 05:26:25 -06:00 committed by GitHub
parent 3e52d54586
commit 7c1fff3495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -243,7 +243,7 @@ see also `v help build`.
compiler, on the command line, without writing an .rsp file first.
-no-std
By default, V passes -std=c99 to the C backend, but some compilers do
By default, V passes -std=gnu99(linux)/-std=c99 to the C backend, but some compilers do
not support that, even though they may be able to compile the produced
code, or have other options that can be tuned to allow it.
Passing -no-std will remove that flag, and you can then use -cflags ''

View File

@ -162,7 +162,11 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
// arguments for the C compiler
ccoptions.args = [v.pref.cflags]
if !v.pref.no_std {
ccoptions.args << '-std=c99 -D_DEFAULT_SOURCE'
if v.pref.os == .linux {
ccoptions.args << '-std=gnu99 -D_DEFAULT_SOURCE'
} else {
ccoptions.args << '-std=c99 -D_DEFAULT_SOURCE'
}
}
ccoptions.wargs = [
'-Wall',

View File

@ -176,7 +176,7 @@ pub mut:
fatal_errors bool // unconditionally exit after the first error with exit(1)
reuse_tmpc bool // do not use random names for .tmp.c and .tmp.c.rsp files, and do not remove them
no_rsp bool // when true, pass C backend options directly on the CLI (do not use `.rsp` files for them, some older C compilers do not support them)
no_std bool // when true, do not pass -std=c99 to the C backend
no_std bool // when true, do not pass -std=gnu99(linux)/-std=c99 to the C backend
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
no_parallel bool
is_vweb bool // skip _ var warning in templates