NvAPI NVAPI_INTERFACE Missing explicit type

帅比萌擦擦* 提交于 2019-12-10 16:35:28

问题


I'm new to c++/cli and would like to write a little managed wrapper for the nvapi.
Now when trying to access some functions (e.g. NvAPI_Initialize)
Visual Studio tells me that this function is not defined:

#include "nvapi.h";    

NvAPIStatus Nv_GPU_ThermalAPI::M_NvAPI_GPU_GetThermalSettings(System::UIntPtr gpuHandle,
                                                              Nv_Thermal_Target sensorIndex,
                                                              [Out] array<Nv_GPU_Thermal_Settings^>^% settings)
{
    NvAPI_Status res = NvAPI_Status::NVAPI_OK;             // OK
    NvPhysicalGpuHandle handle;                            // OK
    NV_GPU_THERMAL_SETTINGS *settings;                     // OK

    res = NvAPI_Initialize();                              // Error
    res = NvAPI_GPU_GetThermalStatus(handle, 0, settings); // same here
}

I've included the nvapi.lib as described here.

Additional VS tells me that in e.g.

NVAPI_INTERFACE NvAPI_Initialize();

NVAPI_INTERFACE is missing an explicit type and that 'int' would be assumed.
Trying to build my code this message turns into C2059: syntax error 'return' and VS cancels the build after 100 errors. I'm using VS 2013 Pro.

Edit: NVAPI_INTERFACE is defined as follow:
'#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl'


回答1:


Found the answer myself. It seems one has to add

#include <Windows.h>

to nvapi.h.



来源:https://stackoverflow.com/questions/30030311/nvapi-nvapi-interface-missing-explicit-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!