简体   繁体   English

无法访问结构字段

[英]Can't access struct fields

Am i doing something wrong here: 我在这里做错什么了吗?

I have 2 structs : 我有2个structs

typedef struct Boundaries{
    int f[11];
    int t[11];
    int d[11];
} boundaries;

typedef struct STNODE {
    char name;
    int addr;
    const char* type;
    int  _size;
    boundaries b;
    int cell_size;
} stnode;

And i create an array of stnode : 我创建了一个stnode数组:

stnode ST[24];

When i try to access the fields of stnode (ie by a dot '.' ) i get all the fields name , addr , type , _size , b , cell_size . 当我尝试访问stnode的字段时(即通过点'.' ),我得到了所有字段name ,即addrtype_sizebcell_size Problem is i can't access b 's fields. 问题是我无法访问b的字段。 This expression: 该表达式:

ST[i].b.

opens up the variables of stnode . 打开stnode的变量。 Shouldn't it let me choose from b 's variables? 它不应该让我从b的变量中选择吗? ( f[] , t[] , d[] ) f[]t[]d[]

Thanks 谢谢

edit: 编辑:

For those who didn't understand what i mean by "opens up the variables", here's a snapshot: 对于那些不了解我的意思是“打开变量”的人,下面是一个快照:

variables_list

Oh now that I know what is this about. 哦,我知道这是怎么回事。

Code::Blocks autocomplete is just plain bad , it will never do what you want it to. 代码::块自动完成只是很糟糕 ,它将永远不会做您想要的事情。 If it does what it's supposed to consider yourself lucky. 如果这样做了,应该认为自己很幸运。 I've been using code::blocks for like 5 years making complicated projects and most of the feature just failed for me because of whatever reasons. 我一直在使用code :: blocks进行复杂的项目已有5年之久了,而大多数功能对我来说却由于任何原因而失败了。 On example is the error tracking, when you double click in the compile error it takes you to the file and the line the error occurred on, well this doesn't work if the path to the source is a relative path. 在示例中是错误跟踪,当您双击编译错误时,它会将您带到文件和发生错误的行,并且如果源路径是相对路径,则此行不通。 All I'm saying with this is that parsing is not the best and I've even seen the auto completion system simply crash under the hood refusing the show the help, I had to restart to make it work again. 我要说的是,解析不是最好的,我什至看到自动完成系统在引擎盖下崩溃,拒绝显示帮助,我不得不重新启动以使其再次运行。

Other than these some idoms affect how the auto completion handles things. 除了这些之外,其他一些因素也会影响自动完成功能的处理方式。 One of the most direct is the perprocessor, if a preprocessor directive handles the definition and you have to specify that explicitly the auto-completion will ignore that. 最直接的方法之一是perprocessor,如果preprocessor指令处理了该定义,并且您必须明确指定自动完成将忽略该定义。 One way to check if it's a problem with the auto-completion system simply copy the defintion you put in your question directly into the file you're using if it's not already there. 检查自动完成系统是否有问题的一种方法是,将问题中的定义直接复制到正在使用的文件中(如果尚未存在)。 If it doesn't work there, you can't do much about it. 如果它在那里不起作用,那么您将无能为力。 If it does work you should check how and where you include these defintions because it's possible that some preprocessor directive just knocks it out making it invisible for the auto-completion system. 如果它可以正常工作,则应检查这些定义的方式和位置,因为某些预处理器指令可能会将其删除,从而使其对自动完成系统不可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM