diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 2ffb75afa0b342..0a9fb98eb5e860 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -792,6 +792,17 @@ pub fn (mut g Gen) init() { g.cheaders.writeln(g.pref.custom_prelude) } else if !g.pref.no_preludes { g.cheaders.writeln('// Generated by the V compiler') + if g.pref.relaxed_gcc14 { + // See https://gcc.gnu.org/gcc-14/porting_to.html#c-code-generators: + g.cheaders.writeln(' +#if defined __GNUC__ && __GNUC__ >= 14 +#pragma GCC diagnostic warning "-Wimplicit-function-declaration" +#pragma GCC diagnostic warning "-Wincompatible-pointer-types" +#pragma GCC diagnostic warning "-Wint-conversion" +#pragma GCC diagnostic warning "-Wreturn-mismatch" +#endif +') + } if g.pref.os == .wasm32 { g.cheaders.writeln('#define VWASM 1') // Include instead of for WASM target diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 0c87419298ab36..f37fc529cb5ae8 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -237,6 +237,8 @@ pub mut: warn_about_allocs bool // -warn-about-allocs warngs about every single allocation, e.g. 'hi $name'. Mostly for low level development where manual memory management is used. // temp // use_64_int bool + // forwards compatibility settings: + relaxed_gcc14 bool = true // turn on the generated pragmas, that make gcc versions > 14 a lot less pedantic. The default is to have those pragmas in the generated C output, so that gcc-14 can be used on Arch etc. } pub struct LineInfo { @@ -609,6 +611,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin res.no_preludes = true res.build_options << arg } + '-no-relaxed-gcc14' { + res.relaxed_gcc14 = false + } '-prof', '-profile' { res.profile_file = cmdline.option(args[i..], arg, '-') res.is_prof = true