我正在使用 Android NDK 进行编译,并确认设置 -fvisibility=hidden (使用 set(CMAKE_CXX_VISIBILITY_PRESET hide))会大大减小二进制文件的大小。但是,当我添加一个 attribute ((可见性(“默认”)))时,它的大小就会恢复,并且臃肿地显示我显然应该隐藏的符号。
这就是我设置该属性的方式
__attribute__((__visibility__("default")))
bool MethodName(const std::string& parameter) noexcept;
谁能告诉我哪里出错了?
你的属性看起来格式不正确(我认为?)。
引用你的片段:
__attribute__((__visibility__("default")))
应该是
__attribute__((visibility ("default")))
(参考此 GCC wiki)。