English 中文(简体)
视线器在自己的图书馆内不完整
原标题:Dereferencing pointer to incomplete type inside own library

I have several struct: edge, vertex, graph in my library. I want to hide body of that structs from user (user have to use API), so in header file (eg. edge.h) I ve just put:

typedef struct edge edge_t;

And definition of edge struct is in edge.c

struct edge {...};

这种做法是完美的,但我不想从我自己的法典中掩盖结构。 我想在前线使用:c

vertex_t v;
v.some_attribute = x;

Now I get dereferencing pointer to incomplete type errors, is it possible to fix that? Is there any other option that use accessors (like user) for all struct elements?

最佳回答

如果你需要从其他来源的档案中利用结构,就需要对结构作出完整的定义。 因此,解决办法是将<代码>struct wei{ ∗ / }列入标题文件中,并在需要时列入标题。

问题回答

Joachim Pileborg是正确的。

汇编者需要了解能够与之合作的结构规模。 防止这种情况的唯一途径是迫使用户使用点。

www.un.org/Depts/DGACM/index_french.htm

汇编者知道点人的规模,因此,它知道需要为之分配多少空间。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签