Reputation: 173
I have the following code:
namespace rm {
namespace lib {
class Object {
public:
Object() {printf("Hi\n");}
};
}
}
Now I wanted to compile the class into an shared library using g++ -Wall -Wno-unused -Werror -fPIC -g -Iinclude/ -c -O0 -o object.o object.cpp
and g++ --shared -o librm.so object.o
. Compilation works with no problems, however after checking the resulting library with nm librm.so | c++filt
, rm::lib::Object::Object()
is nowhere to be found. GCC gives out no warning, even with -Wextra enabled.
G++ version is (Raspbian 4.9.2-10) 4.9.2
Upvotes: 1
Views: 341
Reputation: 217970
Code defined in class are implicitly marked as inline
(and it is not used), and so not saved in file.
Upvotes: 5