Closed LittlePox closed 2 years ago
Cpp code using not/and/or as boolean operator will get compilation error. Using !/&&/|| is fine.
The below code complains as:
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\user\AppData\Local\Programs\Python\Python38\Lib\site-packages\pybind11\include "-IC:\Program Files\Python38\Lib\site-packages\pybind11\include" "-IC:\Program Files\Python38\include" "-IC:\Program Files\Python38\Include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /EHsc /Tpexample.cpp /Fobuild\temp.win-amd64-3.8\Release\example.obj /O2 /std:c++17 example.cpp example.cpp(4): error C2146: syntax error: missing“;”(before identifier “and”) example.cpp(4): error C2065: “and”: undeclared identifier example.cpp(4): error C2146: syntax error: missing“;”(after identifier “b”) error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x64\cl.exe' failed with exit code 2
#include <pybind11/pybind11.h> bool and_bool(bool a, bool b) { return a and b; } PYBIND11_MODULE(example, m) { m.def("and_bool", &and_bool, "and_bool"); }
Opps never mind. adding -fpermissive and it compiles.
Required prerequisites
Problem description
Cpp code using not/and/or as boolean operator will get compilation error. Using !/&&/|| is fine.
The below code complains as:
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\user\AppData\Local\Programs\Python\Python38\Lib\site-packages\pybind11\include "-IC:\Program Files\Python38\Lib\site-packages\pybind11\include" "-IC:\Program Files\Python38\include" "-IC:\Program Files\Python38\Include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /EHsc /Tpexample.cpp /Fobuild\temp.win-amd64-3.8\Release\example.obj /O2 /std:c++17 example.cpp example.cpp(4): error C2146: syntax error: missing“;”(before identifier “and”) example.cpp(4): error C2065: “and”: undeclared identifier example.cpp(4): error C2146: syntax error: missing“;”(after identifier “b”) error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x64\cl.exe' failed with exit code 2
Reproducible example code