Skip to content

Conversation

@jwillemsen
Copy link
Member

@jwillemsen jwillemsen commented Aug 14, 2025

* docs/templates/bmake.txt:
* templates/bmake.mpd:

Summary by CodeRabbit

  • New Features

    • Build templates now support selecting the ISO C++ standard (c++14, c++17, c++20, c++23) via a new configurable variable. When set, the appropriate compiler flag is applied automatically.
  • Documentation

    • Added guidance on the new language standard variable, including supported values and how it influences compilation.

@coderabbitai
Copy link

coderabbitai bot commented Aug 14, 2025

Walkthrough

Adds a new templated variable languagestandard to the bmake documentation and hooks it into the build template so CCFLAGS can include -std= when defined.

Changes

Cohort / File(s) Summary of Changes
Documentation: bmake template variables
docs/templates/bmake.txt
Documents new variable languagestandard (“Which version of ISO C++ standard to compile against (c++14, c++17, c++20, c++23)”), placed after exeflags and before libflags in the public variable list.
Build template: C++ standard flag injection
templates/bmake.mpd
Updates CCFLAGS to append -std=<%languagestandard%> when languagestandard is defined; adds a non-functional blank line after CCFLAGS.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

I twitch my ears at flags anew,
A nibble of C++ I’ll chew—
c++14? Or 23?
Set the switch and let it be.
With makefiles neat and standards true,
This bunny builds—hip-hop—woo! 🐇🛠️

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/templates/bmake.txt (1)

22-22: Clarify scope (C++-only) and compiler support in the description of languagestandard

Make it explicit this affects C++ compilation and only when the compiler understands -std=… to avoid confusion across compilers.

Proposed tweak:

-languagestandard = Which version of ISO C++ standard to compile against (c++14, c++17, c++20, c++23)
+languagestandard = C++ language standard to compile against (e.g., c++14, c++17, c++20, c++23). Applied only when the selected compiler supports -std=...

Also, please confirm whether this template is ever used with compilers that do not support -std= (e.g., non-GNU/Clang style), so we can consider adding a compiler-conditional guard if needed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6d96a69 and 628e866.

📒 Files selected for processing (2)
  • docs/templates/bmake.txt (1 hunks)
  • templates/bmake.mpd (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: VS2022Debug64
  • GitHub Check: VS2022Release32
  • GitHub Check: windows-2022 vs2022
  • GitHub Check: macos-14-C++17
  • GitHub Check: macos-13-C++17
  • GitHub Check: ubuntu-24.04 g++-10

RC = <%rc%>
LIBFLAGS = <%libflags%>
CCFLAGS = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%>
CCFLAGS = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%><%if(languagestandard)%> -std=<%languagestandard%><%endif%>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Do not append -std=… to CCFLAGS; it will be applied to C sources too and can break C builds

CCFLAGS is used for both C and C++ compilation rules in this template (.c, .cc, .cxx, .cpp, .C). Adding a C++ -std flag here will propagate to .c compilations, which Clang/GCC will reject (e.g., “invalid argument '-std=c++17' not allowed with 'C'”). This is a latent build break for projects containing C sources.

Minimal fix within this line:

-CCFLAGS      = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%><%if(languagestandard)%> -std=<%languagestandard%><%endif%>
+CCFLAGS      = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%>

Follow-up (outside this hunk): introduce a separate flag used only by C++ rules and inject it into C++-only compile patterns (.cpp/.cxx/.cc/.C), not .c. Example:

Make variable definition near CCFLAGS:

CXX_STD_FLAG =<%if(languagestandard)%> -std=<%languagestandard%><%endif%>

Update compile commands for C++ sources by adding $(CXX_STD_FLAG) after $(CCFLAGS), e.g.:

  • Parallel .cpp rule (Line 333):
    From:
    $(CC) ... $(CCFLAGS) $(CFLAGS) ...
    To:
    $(CC) ... $(CCFLAGS) $(CXX_STD_FLAG) $(CFLAGS) ...
  • .cpp/.cxx/.cc/.C rules (Lines 338, 343, 347, 351):
    From:
    $(CC) ... $(CCFLAGS) $(CFLAGS) ...
    To:
    $(CC) ... $(CCFLAGS) $(CXX_STD_FLAG) $(CFLAGS) ...
  • Per-file rule with transdir/buildflags (Line 361):
    From:
    $(CC) ... $(CCFLAGS) $(CFLAGS) ...
    To:
    $(CC) ... $(CCFLAGS) $(CXX_STD_FLAG) $(CFLAGS) ...

Please confirm whether projects using this template include any .c sources. If they never do, we can keep the current approach; otherwise, the refactor above avoids C builds failing when languagestandard is set.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Show templates/bmake.mpd (first 220 lines) with numbers ==="
if [ -f templates/bmake.mpd ]; then
  nl -ba templates/bmake.mpd | sed -n '1,220p'
else
  echo "templates/bmake.mpd not found"
fi

echo
echo "=== Search for 'languagestandard' in repository ==="
rg "languagestandard" -n || true

echo
echo "=== Search for CCFLAGS definitions/usages across repo ==="
rg "CCFLAGS" -n || true

echo
echo "=== Show parts of templates/bmake.mpd around common compile rules (lines 300-420) ==="
if [ -f templates/bmake.mpd ]; then
  nl -ba templates/bmake.mpd | sed -n '300,420p'
fi

Length of output: 327


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="templates/bmake.mpd"

echo "=== Show templates/bmake.mpd lines 1-220 ==="
if [ -f "$FILE" ]; then
  awk 'NR>=1 && NR<=220{printf("%4d: %s\n", NR, $0)}' "$FILE"
else
  echo "$FILE not found"
fi

echo
echo "=== Show templates/bmake.mpd lines 280-420 ==="
if [ -f "$FILE" ]; then
  awk 'NR>=280 && NR<=420{printf("%4d: %s\n", NR, $0)}' "$FILE"
fi

echo
echo "=== Search for 'languagestandard' in repo ==="
if command -v rg >/dev/null 2>&1; then
  rg -n "languagestandard" || true
else
  grep -RIn "languagestandard" || true
fi

echo
echo "=== Search for CCFLAGS, CFLAGS, CXXFLAGS, and CXX occurrences in repo ==="
if command -v rg >/dev/null 2>&1; then
  rg -n "CCFLAGS|CFLAGS|CXXFLAGS|CXX" || true
else
  grep -RIn "CCFLAGS\|CFLAGS\|CXXFLAGS\|CXX" || true
fi

echo
echo "=== Show any lines mentioning -std= in the repo ==="
if command -v rg >/dev/null 2>&1; then
  rg -n --hidden --no-ignore-vcs "\-std=" || true
else
  grep -RIn --binary-files=without-match "\-std=" || true
fi

Length of output: 23905


Do not put -std= into CCFLAGS — it will be passed to C compilations and can break C builds

Short reason: templates/bmake.mpd currently places -std=<%languagestandard%> inside CCFLAGS (confirmed at templates/bmake.mpd:100). CCFLAGS is used by the .c rule and per-file rules (see templates/bmake.mpd:353–355, 357–362), so C compiler invocations will receive C++ -std flags and may fail.

Files/locations to change

  • templates/bmake.mpd
    • Line 100: remove the <%if(languagestandard)%> -std=... piece from CCFLAGS.
    • Insert a C++-only variable right after CCFLAGS, e.g. CXX_STD_FLAG.
    • Update all C++ compile rules to use $(CXX_STD_FLAG): parallel .cpp rule (≈line 333), .cpp/.cxx/.cc/.C rules (≈338, 343, 347, 351), and the per-file rule block (≈357–362). For the per-file rules, add $(CXX_STD_FLAG) only when the source file is C++ (use the template conditional that checks the source-file language or extension).

Minimal diffs (apply to templates/bmake.mpd)

-CCFLAGS      = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%><%if(languagestandard)%> -std=<%languagestandard%><%endif%>
+CCFLAGS      = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%>

+# C++-only standard flag
+CXX_STD_FLAG =<%if(languagestandard)%> -std=<%languagestandard%><%endif%>

Example compile-rule change (repeat for .cpp/.cxx/.cc/.C and parallel .cpp rules):

-  $(CC) ... $(CCFLAGS) $(CFLAGS) $(WARN_FLAGS) -c ...
+  $(CC) ... $(CCFLAGS) $(CXX_STD_FLAG) $(CFLAGS) $(WARN_FLAGS) -c ...

For per-file rules generated for each source file, conditionally add $(CXX_STD_FLAG) only when that source file is C++:

... $(CCFLAGS) <%if(source-file-is-cxx)%> $(CXX_STD_FLAG)<%endif%> $(CFLAGS) ...

Please confirm whether projects using this template contain any .c sources; if they do, apply the fix above. If none contain C sources, leaving the current template is harmless but fragile if a .c is later added.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CCFLAGS = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%><%if(languagestandard)%> -std=<%languagestandard%><%endif%>
CCFLAGS = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%>
# C++-only standard flag
CXX_STD_FLAG =<%if(languagestandard)%> -std=<%languagestandard%><%endif%>
🤖 Prompt for AI Agents
In templates/bmake.mpd around line 100, remove the <%if(languagestandard)%>
-std=<%languagestandard%><%endif%> piece from CCFLAGS so -std= is not passed to
C compilations; immediately after CCFLAGS add a new variable (e.g. CXX_STD_FLAG)
that expands to <%if(languagestandard)%> -std=<%languagestandard%><%endif%>;
update all C++ compile rules to use $(CXX_STD_FLAG) instead of relying on
CCFLAGS — specifically the parallel .cpp rule (~line 333) and the
.cpp/.cxx/.cc/.C rules (~lines 338, 343, 347, 351) — and in the per-file rule
block (~lines 357–362) conditionally append $(CXX_STD_FLAG) only when the source
file is C++ using the template conditional for source-file language/extension;
finally, verify whether projects using this template contain any .c sources and
if so apply these changes, otherwise note that leaving -std in CCFLAGS would be
fragile if a .c file is later added.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
templates/bmake.mpd (1)

100-100: Confirm intended precedence for -std: it currently overrides -std set via ccflags/compile_flags

Placing languagestandard last means it wins when multiple -std flags are present. If you prefer user-specified compile_flags to take precedence, swap the order.

Apply this diff to let compile_flags override languagestandard:

-CCFLAGS      = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%><%if(languagestandard)%> -std=<%languagestandard%><%endif%>
+CCFLAGS      = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(languagestandard)%> -std=<%languagestandard%><%endif%><%if(compile_flags)%> <%compile_flags%><%endif%>
docs/templates/bmake.txt (1)

22-22: Tighten wording and punctuation; clarify C++-only intent

Minor grammar fix and explicit note that it pertains to C++ sources. Also adds terminal punctuation for consistency.

-languagestandard = Which version of ISO C++ standard to compile against (c++14, c++17, c++20, c++23)
+languagestandard = Specify the ISO C++ standard for C++ sources (e.g., c++14, c++17, c++20, c++23).
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6d96a69 and 628e866.

📒 Files selected for processing (2)
  • docs/templates/bmake.txt (1 hunks)
  • templates/bmake.mpd (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/templates/bmake.txt

[grammar] ~22-~22: There might be a mistake here.
Context: ...table. languagestandard = Which version of ISO C++ standard to compile against (c+...

(QB_NEW_EN)


[grammar] ~22-~22: There might be a mistake here.
Context: ...ile against (c++14, c++17, c++20, c++23) libflags = Flags that are required to cr...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: VS2022Debug64
  • GitHub Check: VS2022Release32
  • GitHub Check: macos-14-C++17
  • GitHub Check: macos-13-C++17
  • GitHub Check: ubuntu-24.04 g++-10

Comment on lines +100 to +101
CCFLAGS = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%><%if(languagestandard)%> -std=<%languagestandard%><%endif%>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

C++ standard flag may be applied to .c compilations — verify this is acceptable or scope to C++ rules only

CCFLAGS is used by all compile rules, including .c. Appending -std=c++NN here may (a) be rejected by some compilers for C files, or (b) flip .c files into C++ mode. This can silently change semantics or fail builds in mixed C/C++ projects.

  • If all supported Borland/Embarcadero compilers used via this template accept -std=c++NN on .c inputs (or always compile as C++), then OK.
  • Otherwise, consider moving the -std=<%languagestandard%> addition into only the C++ pattern rules (.cpp/.cxx/.cc/.C) instead of CCFLAGS.

I can provide a follow-up patch that scopes the flag to C++-only rules if you confirm this is needed.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Repository root: $(pwd)"
echo
echo "1) Show templates/bmake.mpd (first 400 lines):"
echo "------------------------------------------------"
if [ -f "templates/bmake.mpd" ]; then
  sed -n '1,400p' templates/bmake.mpd || true
else
  echo "templates/bmake.mpd not found"
fi
echo
echo "2) Search for CCFLAGS, -std and compile rule patterns:"
echo "------------------------------------------------"
rg -n --hidden -S 'CCFLAGS|\-std=|languagestandard|%.o: %.c|%.o: %.cpp|%.o: %.cxx|%.o: %.cc|\.c:|\.cpp:|\.cxx:|\.cc:' || true
echo
echo "3) Show lines around occurrences of CCFLAGS:"
echo "------------------------------------------------"
rg -n --hidden -S -n 'CCFLAGS' -n --line-number -n -H -S || true
echo
echo "4) Grep for common compile command usages (CC, CXX, CFLAGS, CXXFLAGS):"
echo "------------------------------------------------"
rg -n --hidden -S '\$\(CC\)|\$\(CXX\)|CFLAGS|CXXFLAGS' || true

Length of output: 27004


Scope -std=<%languagestandard%> to C++ compile rules in templates/bmake.mpd

Verified: CCFLAGS contains -std=<%languagestandard%> and that CCFLAGS is used by all compile rules (including .c), so a C++ standard flag will be passed to C compilations.

Files/locations to fix

  • templates/bmake.mpd:100 — CCFLAGS includes <%if(languagestandard)%> -std=<%languagestandard%><%endif%>
  • templates/bmake.mpd:333–361 — .cpp/.cxx/.cc/.C/.c compile rules all use $(CCFLAGS) (so the -std flag will reach .c compilations)

Suggested change (minimal)

  • Remove the languagestandard bit from CCFLAGS and add it only to C++ rules (or introduce a new CPP-specific var):
    Original:
CCFLAGS = $(CC_CFLAGS)...<%if(languagestandard)%> -std=<%languagestandard%><%endif%>

Change to:

CCFLAGS = $(CC_CFLAGS)...  # no -std here

And in the C++ rules (example non-parallel .cpp rule) append the flag:

.cpp$(OBJ_EXT):
  $(CC) ... $(CCFLAGS) $(CFLAGS) <%if(languagestandard)%> -std=<%languagestandard%><%endif%> $(WARN_FLAGS) -c -o $(@D)\$(@F) $<

If you want, I can prepare a PR that moves the -std into the C++ rules (or introduces a CPP_STD_FLAGS variable and uses it only for the C++ patterns).

🤖 Prompt for AI Agents
In templates/bmake.mpd around lines 100 and 333–361, CCFLAGS currently contains
the C++ standard flag which gets applied to C compilations; remove the
<%if(languagestandard)%> -std=<%languagestandard%><%endif%> fragment from
CCFLAGS and instead add the standard flag only to C++ compile rules by either
(A) introducing a new CPP_STD_FLAGS (or CPPFLAGS/CPP_CFLAGS) conditional var
that expands to <%if(languagestandard)%> -std=<%languagestandard%><%endif%> and
appending that var to all .cpp/.cxx/.cc/.C pattern rules, or (B) directly
appending the existing <%if(languagestandard)%>
-std=<%languagestandard%><%endif%> to each C++ pattern recipe; ensure C pattern
rules keep using only CCFLAGS so they do not receive the C++ -std flag.

@jwillemsen jwillemsen merged commit 9346de8 into DOCGroup:master Aug 14, 2025
12 checks passed
@jwillemsen jwillemsen deleted the jwi-bmakelanguagestandard branch August 14, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant