Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error C2220: 以下警告被视为错误 (编译源文件 #4296

Closed
ruanych opened this issue Nov 15, 2021 · 8 comments
Closed

error C2220: 以下警告被视为错误 (编译源文件 #4296

ruanych opened this issue Nov 15, 2021 · 8 comments

Comments

@ruanych
Copy link

ruanych commented Nov 15, 2021

IMPORTANT: Please use the following template to report the bug.

Before submitting:


Describe the bug
When I used the tutorial here to compile Open3D on Windows 10, a lot of similar errors appeared.

error C2220: 以下警告被视为错误 (编译源文件

It may be the default settings of VS2019 or incorrect settings in some places, which caused the compilation warning level to be too high. Microsoft's explanation is here.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repository source code and create a directory
git clone --recursive https://github.com/intel-isl/Open3D
git submodule update --init --recursive
mkdir build && cd build
  1. Run cmake
cmake -G "Visual Studio 16 2019" -A x64  ..
cmake --build . --config Release --target ALL_BUILD
  1. See error

Expected behavior
Hope to get the warning level set from Open3D.

Screenshots
help

Environment (please complete the following information):

  • Operating system: Windows 10 64-bit
  • Python version: Python 3.8
  • Open3D version: 0.13.0 (The latest source code)
  • Is this remote workstation?: no
  • How did you install Open3D?: build from source Visual Studio 2019
@yxlao
Copy link
Collaborator

yxlao commented Nov 15, 2021

For a workaround, try disabling the C4819 warning.

Add

/wd4819

to

set(DISABLE_MSVC_WARNINGS
/Wv:18 # ignore warnings introduced in Visual Studio 2015 and later.
/wd4201 # non-standard extension nameless struct (filament includes)
/wd4310 # cast truncates const value (filament)
/wd4505 # unreferenced local function has been removed (dirent)
/wd4127 # conditional expression is const (Eigen)
/wd4146 # unary minus operator applied to unsigned type, result still unsigned (UnaryEWCPU)
/wd4189 # local variable is initialized but not referenced (PoissonRecon)
/wd4324 # structure was padded due to alignment specifier (qhull)
/wd4706 # assignment within conditional expression (fileIO, ...)
/wd4100 # unreferenced parameter (many places in Open3D code)
/wd4702 # unreachable code (many places in Open3D code)
/wd4244 # implicit data type conversion (many places in Open3D code)
/wd4245 # signed/unsigned mismatch (visualization, PoissonRecon, ...)
/wd4267 # conversion from size_t to smaller type (FixedRadiusSearchCUDA, tests)
/wd4305 # conversion to smaller type in initialization or constructor argument (examples, tests)
)

@ruanych
Copy link
Author

ruanych commented Nov 16, 2021

When I running command cmake --build . --config Release --target ALL_BUILD, there was an error here

C:\Environment\Open3D\Open3D\cpp\open3d\visualization\visualizer\GuiVisualizer.cpp(682,11): fatal error C1017: 无效的整
数常量表达式 [C:\Environment\Open3D\build\cpp\open3d\visualization\visualization.vcxproj]

position

I added information output in CMakeLists.txt, it is incredible that it entered the if(WIN32) branch, but my operating system is x64.

@ruanych
Copy link
Author

ruanych commented Nov 16, 2021

When I running command cmake --build . --config Release --target ALL_BUILD, there was an error here

C:\Environment\Open3D\Open3D\cpp\open3d\visualization\visualizer\GuiVisualizer.cpp(682,11): fatal error C1017: 无效的整
数常量表达式 [C:\Environment\Open3D\build\cpp\open3d\visualization\visualization.vcxproj]

position

I added information output in CMakeLists.txt, it is incredible that it entered the if(WIN32) branch, but my operating system is x64.

I found a possibility and tried it, WIN32 was indeed used as a string.
see https://stackoverflow.com/questions/53425282/generator-expression-evaluates-win32-variable-to-true-even-not-on-windows

In the generator expression

$<BOOL:WIN32>

CMake evaluates "WIN32" as a string, not as a variable. Because this string doesn't correspond to any false pattern, it is evaluated as TRUE.

You need to dereference the variable for check its value:

$<BOOL:${WIN32}>

@ruanych
Copy link
Author

ruanych commented Nov 16, 2021

Oh no, I check WIN32 after project(...), it is 1.

@ruanych
Copy link
Author

ruanych commented Nov 16, 2021

I repeated all the steps and finally succeeded, thank you very much for your help. @yxlao

@ruanych
Copy link
Author

ruanych commented Nov 16, 2021

To sum up, if you compile Open3D from source code, the following error occurs:

error C2220: 以下警告被视为错误 (编译源文件

help

try disabling the C4819 warning

Add

/wd4819

to

set(DISABLE_MSVC_WARNINGS
/Wv:18 # ignore warnings introduced in Visual Studio 2015 and later.
/wd4201 # non-standard extension nameless struct (filament includes)
/wd4310 # cast truncates const value (filament)
/wd4505 # unreferenced local function has been removed (dirent)
/wd4127 # conditional expression is const (Eigen)
/wd4146 # unary minus operator applied to unsigned type, result still unsigned (UnaryEWCPU)
/wd4189 # local variable is initialized but not referenced (PoissonRecon)
/wd4324 # structure was padded due to alignment specifier (qhull)
/wd4706 # assignment within conditional expression (fileIO, ...)
/wd4100 # unreferenced parameter (many places in Open3D code)
/wd4702 # unreachable code (many places in Open3D code)
/wd4244 # implicit data type conversion (many places in Open3D code)
/wd4245 # signed/unsigned mismatch (visualization, PoissonRecon, ...)
/wd4267 # conversion from size_t to smaller type (FixedRadiusSearchCUDA, tests)
/wd4305 # conversion to smaller type in initialization or constructor argument (examples, tests)
)

@ruanych ruanych closed this as completed Nov 16, 2021
@yuecideng
Copy link
Collaborator

Should we add this

For a workaround, try disabling the C4819 warning.

Add

/wd4819

to

set(DISABLE_MSVC_WARNINGS
/Wv:18 # ignore warnings introduced in Visual Studio 2015 and later.
/wd4201 # non-standard extension nameless struct (filament includes)
/wd4310 # cast truncates const value (filament)
/wd4505 # unreferenced local function has been removed (dirent)
/wd4127 # conditional expression is const (Eigen)
/wd4146 # unary minus operator applied to unsigned type, result still unsigned (UnaryEWCPU)
/wd4189 # local variable is initialized but not referenced (PoissonRecon)
/wd4324 # structure was padded due to alignment specifier (qhull)
/wd4706 # assignment within conditional expression (fileIO, ...)
/wd4100 # unreferenced parameter (many places in Open3D code)
/wd4702 # unreachable code (many places in Open3D code)
/wd4244 # implicit data type conversion (many places in Open3D code)
/wd4245 # signed/unsigned mismatch (visualization, PoissonRecon, ...)
/wd4267 # conversion from size_t to smaller type (FixedRadiusSearchCUDA, tests)
/wd4305 # conversion to smaller type in initialization or constructor argument (examples, tests)
)

Should we add this by default? I used vs2022 for building open3d under windows and also encounter this problem. @yxlao

@yxlao
Copy link
Collaborator

yxlao commented May 29, 2022

Should we add this by default? I used vs2022 for building open3d under windows and also encounter this problem. @yxlao

Yes, thanks! @yuecideng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants