I'm learning to use __attribute__ ((visibility("default"))) for symbol export
// a.cpp
class A
{
public:
__attribute__ ((visibility("default"))) void func() {;};
__attribute__ ((visibility("default"))) int cnt;
};
But I ran into the following problem
# g++ -c a.cpp
a.cpp:5:50: warning: ‘visibility’ attribute ignored [-Wattributes]
__attribute__ ((visibility("default"))) int cnt;
^~~
What's the difference between a member function and a member variable? Why can one export a symbol and the other cannot?