Skip to content

Instantly share code, notes, and snippets.

@snoopspy
Last active August 29, 2015 14:19
Show Gist options
  • Save snoopspy/642195da3f91cca811bc to your computer and use it in GitHub Desktop.
Save snoopspy/642195da3f91cca811bc to your computer and use it in GitHub Desktop.
global_object_glog_test
#include <glog/logging.h>
class Obj {
public:
Obj() { DLOG(INFO) << "Obj::Obj()"; }
virtual ~Obj() { DLOG(INFO) << "Obj::~Obj()"; }
void foo() { DLOG(INFO) << "Obj::foo()"; }
} obj; // global instance(constructor is called before main entry)
int main() {
DLOG(INFO) << "beg main";
obj.foo();
DLOG(INFO) << "end main";
}
all:
g++ -o main.o -c main.cpp
g++ -o global_object_glog_test main.o -lglog -pthread
clean:
rm -rf global_object_glog_test
rm -rf *.o
# ./global_object_glog_test
Segmentation fault (core dumped)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment