ue4遇到一个问题 冲突

来源:互联网 发布:mac os 10.12.6 降级 编辑:程序博客网 时间:2024/06/05 17:38

#include <windows.h>中有个#define UpdateResource  UpdateResourceW

ue4中有个类

void UTexture2D::UpdateResource()
{
// Make sure there are no pending requests in flight.
while( UpdateStreamingStatus() == true )
{
// Give up timeslice.
FPlatformProcess::Sleep(0);
}


#if WITH_EDITOR
// Recache platform data if the source has changed.
CachePlatformData();
#endif // #if WITH_EDITOR


// Route to super.
Super::UpdateResource();
}

怎么办,都是系统的,一个是windows系统,一个ue4自带系统,等死

分两个类呗

静态函数只能在声明它的文件当中可见,不能被其他文件所调用,也就是说该静态函数只能在其定义的.cpp或.c中调用,在其它.cpp或.c文件的函数里是不能被调用的。”

解决方案: 对静态函数一般函数形式的封装,只需对那些对外提供接口的静态函数进行封装,每一个静态接口函数对应一个封装的一般形式的函数,调用时,调用这些封装函数即可。

////给一个实际的例子

比如:

1. printStatic.h文件如下,

#ifndef  STATIC_TEST

#define  STATIC_TEST

#include <iostream>

using namespace  std;

static void printStatic();

#endif

2. 对应的printStatic.cpp 定义的函数如下

#include "stdafx.h"

#include "printStatic.h"

static void printStatic()

{

  cout<<"static"<<endl;

}

3. 在主程序中调用这个静态函数

#include "stdafx.h"

#include <iostream>

#include "printStatic.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

printStatic();

 int x;

 cin>>x;

return 0;

}

那么此时,就会出现“静态函数已声明但未定义的错误
怎么解决呢? 很简单用一般的函数封装这个静态函数,参数一一对应即可,在printStatic.h 增加这个封装的函数的声明,
void printStaticWrapper();
然后在在printStatic.cpp 添加这个函数的实现,其实就是调用这个静态函数
void printStaticWrapper()
{
printStatic();
}
最后在主程序调用
printStaticWrapper();
ok,编译通过,顺利运行,输出static
这样就没问题了~~~~

0 0
原创粉丝点击