很明显,在GNU Wiki中阅读可见性。
以这种从C ++教程示例
// classes example
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
void set_values (int,int);
int area() {return width*height;}
};
void Rectangle::set_values (int x, int y) {
width = x;
height = y;
}
Run Code Online (Sandbox Code Playgroud)
是否可以如第一个链接中所示area()公开和set_values(int,int)本地化而不更改代码?
我写了我的makefile文件来获取 .so
someproj.so : someproj.cpp
g++ --std=c++11 -O3 -fPIC -shared someproj.cpp -o someproj.so
Run Code Online (Sandbox Code Playgroud)
修改以通过添加隐藏所有符号 -fvisibility=hidden
someproj.so : someproj.cpp
g++ --std=c++11 -O3 -fvisibility=hidden -fPIC -shared someproj.cpp -o someproj.so
Run Code Online (Sandbox Code Playgroud)
通过修改上面的编译命令是否可以定制公开哪些功能?
当前使用的gcc 4.7.2版本