Mik*_*ail 0 c++ gcc static-variables
有没有办法通过识别GCC用来促进静态变量(我的函数中已存在的变量)的内部(隐藏?)变量来识别函数是否第一次被调用?
我希望从C++代码中获取这些变量.
没有办法依赖编译器的内部,即使你尝试过,也不能保证它不会随着下一个版本而改变.
使用这个常见的习语:
static bool firsttime = true;
if (firsttime)
{
firsttime = false;
// other stuff here
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
607 次 |
| 最近记录: |