error C2275 将此类型用作表达式非法

C2275: “size_t”: 将此类型用作表达式非法,同时还导致一堆变量未定义的bug。

将LuaXml从lua5.1移植到5.2的时候,使用VS2010编译LuaXml_lib.dll的时候碰到了这个错误,然而使用GCC能编译成功。



群上一人遇到问题:在正确的程序中增加KdPrint()调用以输出调试信息,如下:

//
KdPrint(("xxxxxxxDriverEntryxxxxxxx"));

UNICODE_STRING  uszTest;
NTSTATUS        ntStatus;
//

但是增加这个函数调用后,程序就编译出错:error C2275: 'UNICODE_STRING' : illegal use of this type as an expression


百度了一下把问题解决了:


将C代码在VC++中编译,经常会出现error C2275错误,结果是变量的定义位置不对,应该在函数块的最前面。这是一个编程习惯的问题。


在移植c++代码到c的时候,经常会出现一个奇怪的错误:“error C2275: “xxxxx”: 将此类型用作表达式非法”


这个错误是由于c的编译器要求将变量的申明放在一个函数块的头部,而c++没有这样的要求造成的。


解决的办法就是把变量的声明全部放在变量的生存块的开始。



已标记关键词 清除标记
<div><p>When i run <code>python setup.py build develop</code> to install alphapose on windows 10 , error happens:</p> <pre><code> D:\Repo\PoseEstimation\AlphaPose\detector\nms\src\nms_cuda.cpp(9): error C3861: “AT_CHECK”: identifier not found [2/2] C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\nvcc -Xcompiler /MD -Xcompiler /wd4819 -Xcompiler /wd4251 -Xcompiler /wd4244 -Xcompiler /wd4267 -Xcompiler /wd4275 -Xcompiler /wd4018 -Xcompiler /wd4190 -Xcompiler /EHsc -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -IC:\ProgramData\Anaconda3\lib\site-packages\torch\include -IC:\ProgramData\Anaconda3\lib\site-packages\torch\include\torch\csrc\api\include -IC:\ProgramData\Anaconda3\lib\site-packages\torch\include\TH -IC:\ProgramData\Anaconda3\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" -c D:\Repo\PoseEstimation\AlphaPose\detector\nms\src\nms_kernel.cu -o D:\Repo\PoseEstimation\AlphaPose\build\temp.win-amd64-3.8\Release\detector\nms\src/nms_kernel.obj -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=nms_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 C:/ProgramData/Anaconda3/lib/site-packages/torch/include\c10/util/ThreadLocalDebugInfo.h(12): warning: modifier is ignored on an enum specifier C:/ProgramData/Anaconda3/lib/site-packages/torch/include\c10/util/ThreadLocalDebugInfo.h(12): warning: modifier is ignored on an enum specifier nms_kernel.cu ninja: build stopped: subcommand failed. Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 1516, in _run_ninja_build subprocess.run( File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 512, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "setup.py", line 186, in <module> setup( File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "C:\ProgramData\Anaconda3\lib\distutils\core.py", line 148, in setup dist.run_commands() File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 966, in run_commands self.run_command(cmd) File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\ProgramData\Anaconda3\lib\distutils\command\build.py", line 135, in run self.run_command(cmd_name) File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\build_ext.py", line 79, in run _build_ext.run(self) File "C:\ProgramData\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run _build_ext.build_ext.run(self) File "C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py", line 340, in run self.build_extensions() File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 653, in build_extensions build_ext.build_extensions(self) File "C:\ProgramData\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 195, in build_extensions _build_ext.build_ext.build_extensions(self) File "C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py", line 449, in build_extensions self._build_extensions_serial() File "C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial self.build_extension(ext) File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\build_ext.py", line 196, in build_extension _build_ext.build_extension(self, ext) File "C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py", line 528, in build_extension objects = self.compiler.compile(sources, File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 626, in win_wrap_ninja_compile _write_ninja_file_and_compile_objects( File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 1233, in _write_ninja_file_and_compile_objects _run_ninja_build( File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 1538, in _run_ninja_build raise RuntimeError(message) from e RuntimeError: Error compiling objects for extension </module></code></pre><p>该提问来源于开源项目:MVIG-SJTU/AlphaPose</p></div>
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页