间接水平不同于...... [英] differs in levels of indirection from...

查看:61
本文介绍了间接水平不同于......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个小问题..任何人都可以搞清楚吗?


我在M ++中使用MFC在VS.NET中工作。我有一个基于CWinApp的类

,名为CTestHarnessApp。每当我编译这个时,我就会不断地从''错误中获得''
间接级别'的错误:


CTestHarnessApp theApp;

// CTestHarnessApp * pTheApp =& theApp;

CTestHarnessApp * pTheApp;


(缺少存储类或类型说明符)

(''int''与''CTestHarnessApp *''的间接级别不同)

(''初始化'':无法从''CTestHarnessApp * __ w64''转换为

''int''此转换需要reinterpret_cast,C风格的演员或

函数式演员表)

但是当我编译它时一切都还可以:

CTestHarnessApp theApp;

CTestHarnessApp * pTheApp =& theApp;

// CTestHarnessApp * pTheApp;

// pTheApp =& theApp;

我不明白!!!

BOR

解决方案

blimeyoreill y写道:

我有一个小问题..任何人都可以解决这个问题吗?

我正在使用MFC在C ++的VS.NET中工作。我有一个名为CTestHarnessApp的基于CWinApp的类



只是为了让你知道,MFC本身并不是热门话题。你不应该b $ b b假设这里的人知道MFC或关心讨论它。所以,下次

如果你有特定于MFC的问题(我不是说这个问题),你需要考虑发布到microsoft.public.vc.mfc。回到你的问题。

每当我编译这个时,我总是得到''间接级别与''错误的错误:

CTestHarnessApp theApp;


这声称是一个对象。

// CTestHarnessApp * pTheApp =& theApp;
CTestHarnessApp * pTheApp;


据说这可以声明一个指向同一类型对象的指针。

pTheApp =& theApp;


这里你只是将''theApp''对象的地址分配给一个指针

到同一类型的对象。不应该给你任何问题。

(缺少存储类或类型说明符)
(''int''的间接级别与''CTestHarnessApp *''不同)
(''初始化'':无法从''CTestHarnessApp * __ w64''转换为
''int''此转换需要reinterpret_cast,C风格的演员或
函数式演员表)


嗯,这表明''pTheApp''没有按照你声称的那样声明。

你确定拼写正确吗?你是从你的实际程序中复制并粘贴

还是你输入了它?

但是当我编译它时一切都没问题:
CTestHarnessApp theApp;
CTestHarnessApp * pTheApp =& theApp;


你应该总是试着把这些东西放在同一个声明

声明中以避免拼写错误:


CTestHarnessApp theApp,* pTheApp =& theApp;

// CTestHarnessApp * pTheApp;
// pTheApp =& theApp;

我不明白!!!




Methinks还有更多内容,而不是你所说的。如果我错了(并且

这是不闻所未闻的),那么你正在使用的编译器中有一些非常糟糕的东西。


V


嗨V,

好​​的,只是在某些情况下放入MFC参考,但我看不到

这是如何影响这个问题的。我剪切并粘贴了代码并且编译错误。

我对c ++很新,来自一个坚实的c背景。是否有一个

需要向类声明指针操作符函数

CTestHarnessApp?

BOR


BlimeyOReilly写道:

好的,刚刚在MFC参考文献中删除了一些上下文,但我看不出这是如何影响这个问题的。我剪切并粘贴了代码和编译器错误。
我对c ++很新,来自坚实的c背景。是否需要向类声明一个指针操作符函数
CTestHarnessApp?




不,应该没有必要。


编译器可能存在问题,或者您对平台特定编程的某些方面有所了解。错误消息提到

''__ w64''的事情。如果你正在构建一个64位目标,你应该考虑以某种特定于平台的方式声明你的指针

(我在这里猜测):


CTestHarnessApp * __w64 pTheApp;


请参阅编译器文档,了解对于

指针类型的影响64位模式。我记得有多少痛苦''附近'和''远''

指针给了MS Windows 3的程序员。*。


V


Hi
I''ve a small problem .. can anyone figure it out?

I am working in VS.NET in C++ with MFC. I have a CWinApp-based class
called CTestHarnessApp. I keep getting the ''differs in levels of
indirection from'' error whenever I compile this:

CTestHarnessApp theApp;
//CTestHarnessApp* pTheApp = &theApp;
CTestHarnessApp* pTheApp;
pTheApp = &theApp;

(missing storage-class or type specifiers)
(''int'' differs in levels of indirection from ''CTestHarnessApp *'')
(''initializing'' : cannot convert from ''CTestHarnessApp *__w64 '' to
''int'' This conversion requires a reinterpret_cast, a C-style cast or
function-style cast)
But everything is okay when I compile this:

CTestHarnessApp theApp;
CTestHarnessApp* pTheApp = &theApp;
//CTestHarnessApp* pTheApp;
//pTheApp = &theApp;
Me no understand!!!
BOR

解决方案

blimeyoreilly wrote:

I''ve a small problem .. can anyone figure it out?

I am working in VS.NET in C++ with MFC. I have a CWinApp-based class
called CTestHarnessApp.
Just to let you know, MFC is not topical here by itself. You should not
presume people here know MFC or care about discussing it. So, next time
if you have MFC-specific question (I am not saying this one is) you
should consider posting to microsoft.public.vc.mfc. Back to your problem.
I keep getting the ''differs in levels of
indirection from'' error whenever I compile this:

CTestHarnessApp theApp;
This declares an object, supposedly.
//CTestHarnessApp* pTheApp = &theApp;
CTestHarnessApp* pTheApp;
This, supposedly, declares a pointer to an object of the same type.
pTheApp = &theApp;
And here you''re just assigning the address of ''theApp'' object to a pointer
to an object of the same type. Shouldn''t give you any problem.

(missing storage-class or type specifiers)
(''int'' differs in levels of indirection from ''CTestHarnessApp *'')
(''initializing'' : cannot convert from ''CTestHarnessApp *__w64 '' to
''int'' This conversion requires a reinterpret_cast, a C-style cast or
function-style cast)
Well, that suggests that ''pTheApp'' is not declared as you claim it is.
Are you sure you spelled everything correctly? Did you copy-and-paste
from your actual program or did you type it in?
But everything is okay when I compile this:

CTestHarnessApp theApp;
CTestHarnessApp* pTheApp = &theApp;
You should always try to put those things in the same declaration
statement to avoid typos:

CTestHarnessApp theApp, *pTheApp = &theApp;
//CTestHarnessApp* pTheApp;
//pTheApp = &theApp;
Me no understand!!!



Methinks there is more to it than you''re telling. If I am wrong (and
that is not unheard of), then there is something very screwed up with
the compiler you''re using.

V


Hi V,
Okay, just dropped in the MFC ref for some context, but I cannot see
how it really affects the issue here. I cut and pasted the code and
the compiler errors.
I am fairly new to c++, coming from a solid c background. Is there a
need to declare a pointer operator function to the class
CTestHarnessApp ?
BOR


BlimeyOReilly wrote:

Okay, just dropped in the MFC ref for some context, but I cannot see
how it really affects the issue here. I cut and pasted the code and
the compiler errors.
I am fairly new to c++, coming from a solid c background. Is there a
need to declare a pointer operator function to the class
CTestHarnessApp ?



No, there should be no need for that.

There can be a problem with the compiler or with your understanding of
some aspects of platform-specific programming. The error message mentions
the ''__w64'' thing. If you''re building a 64-bit target you should
probably consider declaring your pointer in some platform-specific way
(and I am guessing here):

CTestHarnessApp * __w64 pTheApp;

Consult with your compiler documentation on what the implications are for
pointer types in a 64-bit mode. I remember how much pain ''near'' and ''far''
pointers gave the programmers of MS Windows 3.*.

V


这篇关于间接水平不同于......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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