简体   繁体   中英

Unused classes removed

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 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM