前瞻性声明一个外部结构 [英] Forward-declaring an extern struct
问题描述
在我开始:
- 的请注意:的那个我不希望
改变主要的设计我在这里是presenting你。 - 随意更改标题,如果你觉得这个人不适合以及
- C ++的标签是在这里,因为该解决方案应相当于为它以及
我有一个头 breakpoints.h
这声明:
typedef struct BreakpointInfo BreakpointInfo;
/*
* Iterate all breakpoints known to the Breakpoints service,
* including breakpoints that are created by other (remote) clients.
*/
typedef void IterateBreakpointsCallBack(BreakpointInfo *, void *);
extern void iterate_breakpoints(IterateBreakpointsCallBack * callback, void * args);
和相应的 breakpoints.c
定义:
struct BreakpointInfo {
Context * ctx;
LINK link_all;
/*
* A lot of members ..
*/
LINK link_hit_count;
};
现在,我想在另一个文件中使用此functionallity context.c
:
Now I would like to use this functionallity in another file context.c
:
#include <tcf/services/breakpoints.h> // The header file
extern BreakpointInfo;
//extern struct BreakpointInfo; // Also did not work
void MyIterateBreakpointsCallBack(/* struct */ BreakpointInfo *bpInfo, void *args)
{
bpInfo->file;
}
void thread_function()
{
// ..
iterate_breakpoints(&MyIterateBreakpointsCallBack, 0);
// ..
}
不过的Intelli-常识告诉我:
But Intelli-Sense tells me:
BreakpointInfo *bpInfo, Error: pointer to incomplete class type is not allowed.
所以,问题是:
- 是甚至可能的没有移动
BreakpointInfo
定义成头文件?
- Is that even possible without moving the definition of
BreakpointInfo
into the header file?
我不想改变这种状况,因为它是一个相当复杂的程序,我不希望做这样的事情,以打破其设计。
I don't want to change that since it is a quite complex program and I don't want to break its' design by doing such things.
这是可能的,我使用了错误的方式,但为什么会有BA一个 iterate_breakpoints()
供我来访问,如果我无法访问<函数code> BreakpointInfo ?
It may be possible that I am using it the wrong way but why would there ba a iterate_breakpoints()
function available for me to access if I could not access BreakpointInfo
?
我希望这是清楚我问。请让我知道如果你需要什么帮助我。
I hope it is clear what I am asking. Please let me know if you need anything to help me.
最好的问候。
推荐答案
我不认为这是可能的,因为在 MyIterateBreakpointsCallBack
你试图访问的成员键入并且这需要在这一点的完整类型。
I don't think it is possible since in MyIterateBreakpointsCallBack
you're trying to access members of the type and this requires a complete type at this point.
我不熟悉,你想一起工作,但一个快速谷歌搜索我暗示其tcf.agent项目的项目。如果这是真的,咋一看在我注意到breakpoints.h文件后,有一个 get_breakpoint_attribute()
,让您的名称/值对的列表。也许这应该给你你需要实现信息的 MyIterateBreakpointsCallBack()
。
I am not familiar with the project you're trying to work with but a quick google search hinted me its the tcf.agent project. If this is true, after a quick look in the breakpoints.h file I noticed that there is a get_breakpoint_attribute()
that gives you a list of name/value pairs. Maybe that should give you the info you need to implement your MyIterateBreakpointsCallBack()
.
这篇关于前瞻性声明一个外部结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!