C++: warning: '…' declared with greater visibility than the type of its field '…::'

前端 未结 3 1950
礼貌的吻别
礼貌的吻别 2021-01-17 23:48

I\'m getting these two warnings (with GCC 4.2 on MacOSX):

/Users/az/Programmierung/openlierox/build/Xcode/../../src/main.cpp:154:0 /Users/az/Programmierung/openliero

3条回答
  •  一个人的身影
    2021-01-18 00:15

    To fix this problem, try one of below.

    1. Use #pragma GCC visibility push() statement like this.

      #pragma GCC visibility push(hidden)
      struct MainLockDetector : Action {
           bool wait(Uint32 time) { /* ... */ }
           int handle() { /* ... */ }
      };
      #pragma GCC visibility pop
      
    2. Use __attribute__ ((visibility("hidden"))) like this.

      struct __attribute__ ((visibility("hidden"))) MainLockDetector : Action {
           bool wait(Uint32 time) { /* ... */ }
           int handle() { /* ... */ }
      };
      
    3. Add the command line option -fvisibility=default.

    For more details, refer http://gcc.gnu.org/wiki/Visibility.

提交回复
热议问题