[求帮助]error C2440: 'return' : cannot convert from 'void'

C++语言 码拜 8年前 (2016-05-04) 1107次浏览
#include <exportfuncs.h>
#include <triangleapi.h>
#include "surface.h"
#include "loadimage.h"
cl_enginefunc_t gEngfuncs;
int g_iTexWidth, g_iTexHeight;
int g_iTexID;
int Initialize(struct cl_enginefuncs_s *pEnginefuncs, int iVersion)
{
	memcpy(&gEngfuncs, pEnginefuncs, sizeof(gEngfuncs));
	return gExportfuncs.Initialize(pEnginefuncs, iVersion);
}
int HUD_VidInit(void)
{
	CreateInterfaceFn fnEngineCreateInterface = g_pMetaHookAPI->GetEngineFactory();
	vgui::ISurface *pSurface = (vgui::ISurface *)fnEngineCreateInterface(VGUI_SURFACE_INTERFACE_VERSION, NULL);
	Surface_Init(pSurface);
	unsigned char *buffer = loadNormalFormat(L"default.png", &g_iTexWidth, &g_iTexHeight);
	g_iTexID = g_pSurface->CreateNewTextureID();
	g_pSurface->DrawSetTextureRGBA(g_iTexID, buffer, g_iTexWidth, g_iTexHeight, true, true);
	delete[] buffer;
	return gExportfuncs.HUD_VidInit();
}
int HUD_Init(void)
{
	return gExportfuncs.HUD_Init();
}
int HUD_Redraw(float time, int intermission)
{
	int iX = 200, iY = 200;
	gEngfuncs.pTriAPI->RenderMode(kRenderTransTexture);
	g_pSurface->DrawSetTexture(g_iTexID);
	g_pSurface->DrawSetColor(255, 255, 255, 255);
	g_pSurface->DrawTexturedRect(iX, iY, iX + g_iTexWidth, iY + g_iTexHeight);

	return gExportfuncs.HUD_Redraw(time, intermission);
}

生成时出现错误:
1>exportfuncs.cpp
1>c:\users\administrator\desktop\wft\metahook\plugins\fuckworld2012\exportfuncs.cpp(36) : error C2440: “return” : cannot convert from “void” to “int”
1>        Expressions of type void cannot be converted to other types

解决方案

20

你设置的无返回值。  然后又return

30

HUD_Init 返回类型是 void ?
int HUD_Init(void)
{
gExportfuncs.HUD_Init();
return  1;
}

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明[求帮助]error C2440: 'return' : cannot convert from 'void'
喜欢 (0)
[1034331897@qq.com]
分享 (0)