AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Mozilla Public License 2.0
2.59k stars 643 forks source link

Compiler error on Visual Studio 2019 #808

Open wallisc opened 4 years ago

wallisc commented 4 years ago

Repro steps:

  1. Get OpenVDB using vcpkg (command line I was using: "vcpkg install openvdb:x64-windows"
  2. Run "vcpkg integrate install" to get vcpkg to includes/libs to be automatically picked up by Visual Studio
  3. Compile anything with "#include <openvdb/openvdb.h>" in VS 2019

The error I get is "error C4146: unary minus operator applied to unsigned type, result still unsigned" coming from NodeMasks.h lines 112 and 134, code below:

return DeBruijn[Index32((v & -v) * 0x077CB531U) >> 27];

Easy fix would probably be to just cast it to an int and then cast it back to a uint after all is said and done

Idclip commented 4 years ago

Hello @wallisc,

The VDB headers are not warning free, this is a known issue. You should be able to easily work around the problem by treating your OpenVDB installation path as a system directory. With GCC/Clang, this is by providing the -isystem flag to your include directory. With MSVC (from VS2017 v15.6), I believe you can use the "/external:I" switch. Note that the MSVC solution is actually more appropriate for your use case as I think that the sole function of that switch is to disable warnings from external headers (where as -isystem will change the include order in other compilers).

cgolchert commented 1 year ago

The VDB headers are not warning free, this is a known issue.

Which is really sad considering their Coding Standards General Practices rule #1 is:

Code must compile without any warning messages at the default warning level.

Idclip commented 10 months ago

Which is really sad considering their Coding Standards General Practices rule #1 is:

Code must compile without any warning messages at the default warning level.

If it's of any consolation, those were written before VDB was officially supported on Windows (and we skipped various MSVC warnings to accelerate that support) - but yes, we should be warning free on all Platforms we support