PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
6.08k stars 1.21k forks source link

Compiler Warnings: Static Functions that should be Static Inline #3324

Open dgovil opened 2 weeks ago

dgovil commented 2 weeks ago

Description of Issue

There are several static functions that the compiler believes should be declared as static inline. These are reported from Apple Clang 16 bundled with Xcode 16, but should reproduce in other compilers with slight variations.

Most are found in pxr/base/vt/wrapArray.h with a few in usd/pxr/imaging/hdSt/unitTestHelper.h. I think this would be a good first issue to get folks used to building USD and make contributions that will help provide cleaner outputs.

The warning is reproduced below:

[1065/4632] Building CXX object pxr/base/vt/CMakeFiles/vt.dir/wrapArray.cpp.o
In file included from /Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.cpp:10:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from /Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.cpp:10:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

[1337/4632] Building CXX object pxr/base/vt/CMakeFiles/vt.dir/arrayPyBuffer.cpp.o
In file included from /Users/dhruvgovil/Projects/usd/pxr/base/vt/arrayPyBuffer.cpp:15:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /Users/dhruvgovil/Projects/usd/pxr/base/vt/arrayPyBuffer.cpp:15:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[3719/4632] Building CXX object pxr/base/vt/CMakeFiles/_vt.dir/wrapArrayBase.cpp.o
In file included from /Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArrayBase.cpp:9:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from /Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArrayBase.cpp:9:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
[3779/4632] Building CXX object pxr/base/vt/CMakeFiles/_vt.dir/wrapValue.cpp.o
In file included from /Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapValue.cpp:15:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from /Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapValue.cpp:15:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
[3783/4632] Building CXX object pxr/usd/sdf/CMakeFiles/_sdf.dir/wrapAssetPath.cpp.o
In file included from /Users/dhruvgovil/Projects/usd/pxr/usd/sdf/wrapAssetPath.cpp:13:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from /Users/dhruvgovil/Projects/usd/pxr/usd/sdf/wrapAssetPath.cpp:13:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
[3810/4632] Building CXX object pxr/usd/sdf/CMakeFiles/_sdf.dir/wrapTimeCode.cpp.o
In file included from /Users/dhruvgovil/Projects/usd/pxr/usd/sdf/wrapTimeCode.cpp:13:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from /Users/dhruvgovil/Projects/usd/pxr/usd/sdf/wrapTimeCode.cpp:13:
/Users/dhruvgovil/Projects/usd/pxr/base/vt/wrapArray.h:307:1: warning: 'static' function 'Vt_ComputeEffectiveRankAndLastDimSize' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  307 | Vt_ComputeEffectiveRankAndLastDimSize(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

[4292/4632] Building CXX object pxr/imaging/hdSt/CMakeFiles/testHdStQualifiers.dir/testenv/testHdStQualifiers.cpp.o
In file included from /Users/dhruvgovil/Projects/usd/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp:17:
/Users/dhruvgovil/Projects/usd/pxr/imaging/hdSt/unitTestHelper.h:215:1: warning: 'static' function '_ToHd' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  215 | _ToHd(const GfCamera::Projection projection)
      | ^~~~~
1 warning generated.
In file included from /Users/dhruvgovil/Projects/usd/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp:17:
/Users/dhruvgovil/Projects/usd/pxr/imaging/hdSt/unitTestHelper.h:215:1: warning: 'static' function '_ToHd' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
  215 | _ToHd(const GfCamera::Projection projection)
      | ^~~~~
1 warning generated.
jesschimein commented 2 weeks ago

Filed as internal issue #USD-10208