Consider the following
// main.cpp
#include <string>
class A {
std::string s;
};
static A a;
int main() {}
Using clang++ main.cpp -Wglobal-constructors
to compile, I get the following warning
main.cpp:6:10: warning: declaration requires a global destructor [-Wglobal-constructors]
My questions are:
- What does this warning mean and why does it happen.
- How to resolve this warning.
Edit:
I tried to add a destructor ~A()
but this warning is still there.