包含 Nvidia 的 nvapi.h 导致编译错误
Include of Nvidia's nvapi.h causes compilation errors
我正在尝试使用NVIDIA的nvapi
,但我有不完全理解的编译错误。也许我使用了错误的编译器?
#include "nvapi.h"
#include <iostream>
int main()
{
printf("Hello nvapi!");
return 0;
}
汇编:g++ nvapi_hello.cpp
输出(由于太长而被截断):
In file included from nvapi_lite_d3dext.h:35:0,
from nvapi.h:6,
from nvapi_hello.cpp:1:
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:134:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Unload();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:134:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Unload();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:134:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Unload();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:153:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:153:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:153:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:174:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetInterfaceVersionString(NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:174:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetInterfaceVersionString(NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:174:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetInterfaceVersionString(NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:319:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GPU_GetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:319:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GPU_GetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:319:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GPU_GetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:669:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargetInfo, NV_TARGET_VIEW_MODE targetView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:669:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargetInfo, NV_TARGET_VIEW_MODE targetView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:669:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargetInfo, NV_TARGET_VIEW_MODE targetView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:808:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:808:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:808:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1030:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetDisplayDriverVersion(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1030:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetDisplayDriverVersion(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1030:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetDisplayDriverVersion(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1159:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1159:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1159:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1167:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1167:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1167:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1209:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1209:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1209:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1216:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1216:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1216:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1251:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumTCCPhysicalGPUs( NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1251:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumTCCPhysicalGPUs( NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1251:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumTCCPhysicalGPUs( NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1282:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumLogicalGPUs(NvLogicalGpuHandle nvGPUHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1282:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumLogicalGPUs(NvLogicalGpuHandle nvGPUHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1282:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumLogicalGPUs(NvLogicalGpuHandle nvGPUHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1308:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetPhysicalGPUsFromDisplay(NvDisplayHandle hNvDisp, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1308:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetPhysicalGPUsFromDisplay(NvDisplayHandle hNvDisp, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
...
我安装了mingw-w64,我正在使用g++
版本:
g++ (x86_64-posix-sjlj-rev2, Built by MinGW-W64 project) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我已從 https://developer.nvidia.com/gameworksdownload#?search=nvapi 下載了 NVIDIA 的 NVAPI SDK
我在这里找到了一个答案,解释了这些变量是在文件nvapi_lite_salstart.h
中使用#define
创建的,然后在文件nvapi_lite_salend.h
中使用#undef
未定义,该文件分别在每个头文件的开头和结尾调用,如nvapi.h
开头所列:
#include"nvapi_lite_salstart.h" //Remove this line
#include"nvapi_lite_common.h"
#include"nvapi_lite_sli.h"
#include"nvapi_lite_surround.h"
#include"nvapi_lite_stereo.h"
#include"nvapi_lite_d3dext.h"
#include"nvapi_lite_salstart.h" //Add this line to fix the errors
如您所见,似乎"salstart"文件只需要移动到列表的末尾,因为由于某种原因它错误地位于顶部。不知道为什么这在Visual Studio中可以正常工作(它没有进行上述修改),但这至少修复了MinGW中的这些错误;但是,nVidia提供的预编译库文件(nvapi.lib
或nvapi64.lib
)与MinGW不兼容,因此您被迫使用MS Visual Studio。
NVIDIA API 中提供的头文件似乎与g++
/GCC 编译器不兼容。所以我选择使用Microsoft的 C/C++ x64 编译器。 我使用CMake
(v3.5.2)创建了一个Visual Studio 2010解决方案,在对我的CMakeLists.txt
文件进行了一些摆弄后,它一直工作正常。
这是我CMakeLists.txt
的内容:
cmake_minimum_required(VERSION 3.5)
include_directories(3rdparty)
link_directories(3rdparty/amd64)
add_executable(nvapi_test nvapi_hello.cpp)
target_link_libraries(nvapi_test nvapi64.lib)
3rdparty
目录包含nvapi64.lib
所在的amd64
文件夹,以及NVAPI的*.h
和*.c
文件。
此外,正如我的问题(@RichardCritten)的评论中所述,我必须在.cpp
文件的顶部添加#include <Windows.h>
才能正确编译。
- std::is_base_of表示ctor编译错误
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- 如何修复sfml c++代码编译错误
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- vscode下的Arduino代码出现意外编译错误
- 第三方 API 中的编译错误 - Visual Studio
- std::cout输出int时出现编译错误
- 奇怪的代码抛出编译错误模板< J,int aSize=10> C2143:语法错误:在"<"之前缺少";"
- 提升图广度优先搜索前置编译错误
- C++ 中的编译错误:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 使用带有 ref 参数的成员函数创建线程时出现编译错误
- 我在C++中遇到了这个奇怪的编译错误
- 在C++中使用 Catch 测试框架编译错误"error: expected ';' at end of declaration list"
- 使用 std::enable_if 限制派生类的模板参数时出现编译错误
- 现代OpenGL和GLEW Libraray的编译错误
- C++ 编译错误:意外的类型名称"字符串":预期的表达式
- C ++程序编译错误,找不到/访问文件
- 使用直接大括号初始化时,C++ 编译错误"声明末尾的预期";"
- 为什么传递非静态成员函数会导致编译错误?