Polyman Documentation - v3.1.0
    Preparing search index...

    Function resolveCppFlags

    • Builds the full list of C++ compile flags: -O2, -std=<cppStandard>, then every item of compiler.flags. A user flag replaces the matching default instead of being added next to it:

      • a -std= (or --std=) flag replaces -std=<cppStandard>,
      • an -O flag (-O0, -O3, -Ofast, ...) replaces -O2. So the command never has two different -std= or -O flags. With onlineJudge (solutions only), -DONLINE_JUDGE is added after the standard, unless compiler.flags already defines ONLINE_JUDGE.

      Parameters

      • Optionaloptions: { cppStandard?: string; onlineJudge?: boolean } = {}

        Compilation overrides

        • OptionalcppStandard?: string

          Standard to use instead of the one from Config.json

        • OptionalonlineJudge?: boolean

          Define ONLINE_JUDGE

      • Optionalconfig: CompilerConfig = ...

        Checked compiler block; read from Config.json when omitted

      Returns string[]

      Flags in order (not shell-quoted)

      If cppStandard or the compiler block is invalid

      // Config.json: { "cppStandard": "c++20", "compiler": { "flags": ["-Wall"] } }
      resolveCppFlags(); // ['-O2', '-std=c++20', '-Wall']
      // Config.json: { "compiler": { "flags": ["-O0", "-std=gnu++17"] } }
      resolveCppFlags(); // ['-O0', '-std=gnu++17']
      resolveCppFlags({ onlineJudge: true }); // ['-O2', '-std=c++23', '-DONLINE_JUDGE']