Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22130

How to use the __attribute__((visibility("default")))?

$
0
0

Reading Visibility in the GNU wiki, it is clear.

Taking this example from C++ Tutorials

// 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;
}

Is it possible to make area() public and set_values(int,int) local as shown in the first link without altering the code?

I wrote my makefile to get the .so

someproj.so : someproj.cpp
    g++ --std=c++11 -O3 -fPIC -shared someproj.cpp -o someproj.so

Modified to make all symbols hidden by adding -fvisibility=hidden

someproj.so : someproj.cpp
    g++ --std=c++11 -O3 -fvisibility=hidden -fPIC -shared someproj.cpp -o someproj.so

Is it possible to customized which functions are exposed by modifying the compilation command above?

Currently using 4.7.2 version of gcc


Viewing all articles
Browse latest Browse all 22130

Trending Articles