【发布时间】:2020-03-30 09:53:18
【问题描述】:
我的场景如下(它在 clang 中有效,但在 gcc 中无效)
liba.hpp:
inline int MY_GLOBAL = 0;
libother.cpp: (dll)
#include "myliba.hpp"
void myFunc() {
//
MYGLOBAL = 28;
}
someexe.cpp:
RunAppThatUsesBothLibAandLibOther();
问题是内联变量在我预期为 28 的地方显示为 0,因为它已经在运行时进行了修改。 MSVC 不同意这一点,但 clang 做了我所期望的事情。
问题是:可以在我的场景中在运行时修改内联变量吗?(我通过取消内联变量解决了这个问题。)
【问题讨论】:
标签: c++ visual-c++ dll clang c++17