-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Server Programmability
-
Fully Compatible
-
ALL
-
Programmability 2025-05-12
-
None
-
3
-
TBD
-
None
-
None
-
None
-
None
-
None
-
None
From Slack cxx-discuss.
https://mongodb.slack.com/archives/C1MT4NHF0/p1746732895054659
Yuhong Zhang: We define MONGO_COMPILER_ALWAYS_INLINE as #define MONGO_COMPILER_ALWAYS_INLINE MONGO_COMPILER_ALWAYS_INLINE_ #if defined(_MSC_VER) #define MONGO_COMPILER_ALWAYS_INLINE_ __forceinline #elif MONGO_COMPILER_HAS_ATTRIBUTE(gnu::always_inline) #define MONGO_COMPILER_ALWAYS_INLINE_ [[gnu::always_inline]] #else #define MONGO_COMPILER_ALWAYS_INLINE_ #endif For a non-member function, gcc requires specifying inline after the attribute [[gnu::always_inline]] or it gives an error error: 'always_inline' function might not be inlinable unless also declared 'inline' [-Werror=attributes] For MSVC, specifying both __forceinline and inline gives you a warning (then treated as error by us) warning C4141: 'inline': used more than once Our current definition of the macro forces you to not use inline or instead you need to suppress the MSVC warning explicitly.
https://mongodb.slack.com/archives/C1MT4NHF0/p1746732895054659
We can use an attribute on MSVC to achieve portable behavior hints that neither compiler will complain about. Thx Yuhong and Guillaume!
- is duplicated by
-
SERVER-104969 Make MONGO_COMPILER_ALWAYS_INLINE a no-op on Windows
-
- Closed
-