In the following code, gcc does not instantiate the NSP::Admin and NSP::Server objects.
It just skips them.
int main(int argc, char **argv)
{
// Here we bootstrap google logging
// we also install the signal handler
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
// now we parse the arguments with gflags
google::ParseCommandLineFlags(&argc, &argv, true);
NSP::Admin admin();
NSP::server server();
DLOG(INFO) << "boost io_service run";
NSP::IOService::getIOService().run();
}
If I add a parameter to the CTORS they are instantiated.
Example :
NSP::Admin admin(1);
NSP::server server(1);
I cannot break point on them with gdb, and stepping skips them.
These two objects register themselves with the boost io service and call a method in their CTORS.
NSP is the project namespace.
Using gcc4.2 on FreeBSD,
glog, gflags and boost asio.
It does not instantiate them because
NSP::Admin admin();does not create any objects.Instead it is a declaration of a function prototype of a function which returns NSP::Admin object and takes void arguments. It is one of those wierd C++ syntaxes. The second one works because, compiler doesn’t get ‘confused’ thinking that it is a function prototype. It can clearly see that you are creating an object.
To create an object using the default constructor use