私は2つの頂点のidを比較する関数を書いています。エラー:構造体または共用体ではないメンバー 'id'の要求
/* Returns whether aim and vertex have the same id */
bool id_eq(void *aim, void *vertex) {
if(*(Vertex)aim.id ==*(Vertex)vertex.id){
return true;
}
return false;
}
aimとvertexは、struct vertex_tの2つのポインタです。
typedef struct graph_t* Graph;
typedef struct vertex_t* Vertex;
/* A vertex is an id, a label and a list of incoming and outgoing edges */
struct vertex_t {
int id;
char *label;
/* A list of vertices representing incoming edges */
List in;
/* A List of vertices representing outgoing edges */
List out;
};
しかし、私はそれをコンパイルすると、エラーが発生したとして「ERROR:メンバーの要求 『』何かない構造体または共用体の」IDを。誰かが私がどこに間違って行ったか教えてもらえますか? >または -
'.'は構造体または共用体でのみ使用できます。 'aim'はポインタです。あなたはおそらく '((Vertex)aim) - > id ==((Vertex)vertex) - > id'を意味します。 –
ポインタのtypedefを避けると、コードが読みやすくなります –
aim - > idを使用しようとしましたが、このエラーはまだ発生しています。 –