Skip to content

Instantly share code, notes, and snippets.

@toulouse
Last active December 27, 2015 17:59
Show Gist options
  • Save toulouse/7366897 to your computer and use it in GitHub Desktop.
Save toulouse/7366897 to your computer and use it in GitHub Desktop.
#include <iostream>
class BlahClass {
public:
BlahClass() {
std::cout << "BlahClass()" << std::endl;
}
~BlahClass() {
std::cout << "~BlahClass()" << std::endl;
}
};
__attribute__((constructor))
void makeStaticBlah() {
std::cout << "makeStaticBlah()" << std::endl;
static BlahClass b;
}
int main(int argc, const char * argv[])
{
std::cout << "Begin" << std::endl;
std::cout << "End" << std::endl;
return 0;
}
makeStaticBlah()
BlahClass()
Begin
End
~BlahClass()
Program ended with exit code: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment