恼人的警告 - 警告LNK4248:未解析的typeref令牌 [英] Annoying warning - warning LNK4248: unresolved typeref token

查看:585
本文介绍了恼人的警告 - 警告LNK4248:未解析的typeref令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C ++ / CLI进行旋转,我遇到了一个恼人的警告:

JNIEnvWrapper.obj:警告LNK4248:'_jmethodID'的未解析的typeref标记(0100000C);图像可能无法运行

JNIEnvWrapper.obj:警告LNK4248:'_jfieldID'的未解析的typeref标记(0100000D);图片可能无法运行



I’m taking C++/CLI for a spin, and I’ve run into an annoying warning:
JNIEnvWrapper.obj : warning LNK4248: unresolved typeref token (0100000C) for '_jmethodID'; image may not run
JNIEnvWrapper.obj : warning LNK4248: unresolved typeref token (0100000D) for '_jfieldID'; image may not run

#pragma managed(push,off)
struct JNIEnv_;
typedef JNIEnv_ JNIEnv;

struct JavaVM_;
typedef JavaVM_ JavaVM;

struct _jfieldID;
typedef _jfieldID *jfieldID;
struct _jmethodID;
typedef _jmethodID *jmethodID;

/* .. code removed ...*/

#pragma managed(pop)







替换上面的部分



Replacing the section above with

#pragma managed(push,off)
#include <jni.h>
#pragma managed(pop)



也无法解决问题...



也没有


doesn't solve the problem either ...

Neither does

#pragma warning( disable : 4248 )





奇怪的是我没有得到关于JNIEnv_或JavaVM_的任何警告。

我只是在托管代码中使用jmethodID和jfieldID。



声明:



Oddly enough I'm not getting any warnings about JNIEnv_ or JavaVM_.
I'm just using jmethodID and jfieldID in managed code.

Declaration:

jmethodID FromReflectedMethod(JavaObject^ method);
jfieldID FromReflectedField(JavaObject^ field);





Implmentation:



Implmentation:

jmethodID JNIEnvWrapper::FromReflectedMethod(JavaObject^ method)
{
	jmethodID result = 0;
	jobject jObj = method->JNINative;
	result = env->FromReflectedMethod(jObj);
	return result;
}
jfieldID JNIEnvWrapper::FromReflectedField(JavaObject^ field)
{
	jfieldID result = 0;
	jobject jObj = field->JNINative;
	result = env->FromReflectedField(jObj);
	return result;
}





因此_jfieldID和_jmethodID被视为不透明类型。 (因为我没有玩JDK的内部,它们几乎不可能是其他任何东西。)代码似乎运行得很好,但我想摆脱警告 - 它们通常是有原因的: )。



有什么想法吗?我很乐意找到一种方法来抑制警告...



问候

Espen Harlinn



So _jfieldID and _jmethodID are treated as opaque types. (As I'm not playing around with the internals of the JDK, they could hardly be anything else.) The code seems to run just fine, but I would like to get rid of the warnings - they are usually there for a reason :).

Any ideas? I'll be happy to just find a way to suppress the warning ...

Regards
Espen Harlinn

推荐答案

您是否看到此主题: http://social.msdn.microsoft.com/Forums/is/vclanguage/thread/0730e965-7299-44ca-8a95-59e2eb23d153 [ ^ ]?



我认为那里有一个合理的解释。您的案例看起来类似于其中一个示例中不完整结构的情况。有人提到,当他们删除

/ clr时警告会消失。我知道你需要CLR标志,但你观察的是同样的吗? JNI是不受管理的,所以如果你移除标志就会消失警告,只是为了实验。



-SA
Did you see this thread: http://social.msdn.microsoft.com/Forums/is/vclanguage/thread/0730e965-7299-44ca-8a95-59e2eb23d153[^]?

I think there is a reasonable explanation there. You case looks similar to the case on incomplete structure in one of the examples. It's mentioned that the warning disappears when they remove
"/clr". I understand you need CLR flag, but do you observer the same? JNI is unmanaged, so the warning should disappear if you remove the flag, just for experiment.

—SA


那么,假结构怎么样?



Sergey Alexandrovich,效果很好:-)



谢谢! : - )
"So, how about fake structure?"

Sergey Alexandrovich, it works well :-)

Thank you! :-)


编辑jni.h文件chang fromestruct _jfieldID到struct _jfieldID {}
edit jni.h file chang frome "struct _jfieldID" to "struct _jfieldID {}"


这篇关于恼人的警告 - 警告LNK4248:未解析的typeref令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆