1

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

4

1 回答 1

5

类中定义的代码被隐式标记为inline(并且未使用),因此不保存在文件中。

于 2015-12-27T17:05:12.150 回答