Skip to content

Mark constants as _INLINE_VAR constexpr. - #2792

Merged
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
StephanTLavavej:inline-constexpr
Jun 16, 2022
Merged

Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
StephanTLavavej:inline-constexpr

Conversation

@StephanTLavavej

Copy link
Copy Markdown
Member

Cameron DaCamara (@cdacamar) explained why he's implementing a new compiler warning:

I have been tightening up c1xx's modules implementation by making the compiler more strict and correct when it comes to assigning out linkage to entities emitted into associated .objs.

This warning will complain about non-inline constants in headers. We're almost completely consistent about using inline in C++17-and-later (or _INLINE_VAR in potentially-C++14), but Cameron found our inconsistent occurrences:

C:\msvc\binaries\x86chk\inc\vector(2113): warning C5260: the constant variable 'std::_VBITS' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\regex(1166): warning C5260: the constant variable 'std::_Buf_incr' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\functional(725): warning C5260: the constant variable 'std::_Space_size' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\regex(1158): warning C5260: the constant variable 'std::_BRE_MAX_GRP' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\regex(1160): warning C5260: the constant variable 'std::_Bmp_max' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\regex(1161): warning C5260: the constant variable 'std::_Bmp_shift' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\regex(1162): warning C5260: the constant variable 'std::_Bmp_chrs' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\regex(1163): warning C5260: the constant variable 'std::_Bmp_mask' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\regex(1164): warning C5260: the constant variable 'std::_Bmp_size' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
C:\msvc\binaries\x86chk\inc\regex(1167): warning C5260: the constant variable 'std::_ARRAY_THRESHOLD' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
  • This fixes all of these occurrences, plus another that I found, _Size_after_ebco_v in .
    • I need to detach the comment there due to wrapping.
  • All are potentially C++14, so they need to use _INLINE_VAR.
  • In , I'm upgrading const to constexpr.
  • In , I'm adding a newline to avoid = alignment, and because typedefs and constants are different.

@StephanTLavavej

Copy link
Copy Markdown
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit ea32e86 into microsoft:main Jun 16, 2022
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) deleted the inline-constexpr branch June 16, 2022 01:35
Igor Zhukov (fsb4000) pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants