Inline variables are only available in C++17 and above #1100
Inline variables are only available in C++17 and above #1100johnDeSilencio wants to merge 2 commits intomozilla:mainfrom
Conversation
…in C++ code generation to support older C++ compilers
emilio
left a comment
There was a problem hiding this comment.
Hmm, but I don't think this works tho, right? If they're not inline, as soon as you include this header from different translation units stuff blows up due to duplicate symbols, doesn't it?
|
The question is, does |
emilio
left a comment
There was a problem hiding this comment.
But without inline you'll get linker errors as soon as you include this header from two translation units right? I think requiring C++17 for allow_static_const is reasonable in 2026.
|
Ah indeed this had been pointed out above, sorry, I jumped directly to the code. |


The Problem
Rust code like this:
generates code like this:
However,
inlinevariables are only available in C++17 and above: Godbolt Link. At my company in particular, we're stuck with C++11 for the foreseeable future (😭)Solution
Make generating associated constants with the
inlinekeyword configurable.In this PR, I add the new
[const]config settingallow_inlinewhich defaults totrue. I also added a test whenallow_inlineis set to false.