Skip to content

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

@dgovil

Description

@dgovil

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIndicates a good issue for first-time contributorshelp wantedIndicates an issue where help and/or a pull request from the community would be very welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions