2016-04-27 4 views
0

tree.hファイル:私はCに誤りを与えている共依存ヘッダを持っています。どうすれば削除できますか?

#ifndef tree 
#define tree 

#include "common.h" 
#include "set.h" 

/*Tree Structure*/ 
typedef struct 
{ 
    Set *set; 
    unsigned int setLength; 
    int vertexLength; 
    int *vertex; 
    int idle; 
    int parent; 
    int level; 
    int numberOfChildren; 
} TreeNode; 

typedef struct 
{ 
    TreeNode* node; 
    int nodeLength; 
    int height; 
} Tree; 

Tree* fill_tree(char *filename, int worldSize, int rank); 
int get_number_of_leaves(Tree *tree); 
TreeNode get_tree_node(int index, Tree* tree); 
TreeNode* get_tree_nodes(Tree* tree); 
int get_tree_nodes_length(Tree* tree); 
void compute_level(int u, Tree* tree); 
void print_tree(Tree* tree); 
int get_max_level(Tree* tree); 
int* create_task_list(Tree* tree, int* taskListLength, int rank); 
int* map(int* taskList, int taskListLength, int* mapLength, int rank); 
void generate_combination_sets(Tree* tree, int nodePerProcess, int rank); 

#endif 

set.hファイル:

#ifndef set 
#define set 

#include "common.h" 
#include "tree.h" 

/*Tree Structure*/ 
typedef struct 
{ 
    int combinationLength; 
    int* combination; 
} Set; 

Set* generate_subsets(int* vertex, int vertexLength, unsigned int pow_set_size, int rank); 
Set* match(Set* parent, unsigned int parentLength, Set* child, unsigned int childLength, TreeNode childNode, TreeNode parentNode, unsigned int* solutionLength, Graph* g, int rank); 
int* union_operation(int* parenteCombination, int parentCombinationLength, int* childCombination, int childCombinationLength, unsigned int* mergedLength, int rank); 
int not_in_solution(Set* solution, int solutionLength , int* merged, unsigned int mergedLength); 
void print_set(Set set); 

#endif 

COMMON.Hファイル:

#ifndef common 
#define common 

// Libraries 

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <math.h> 
#include <pthread.h> 
#include <limits.h> 
#include "mpi.h" 
#include "graph.h" 
#define true 1 
#define false 0 
#endif 

私がエラーを持っているツリーとセットヘッダーファイルは共依存であり、コンパイラはsetがtree.hに見つからないというエラーと、setと同様にエラーが発生します。 common.hファイルにすべてのファイルを含めるべきですか?あなたは別のヘッダファイルに構造体を参照する必要があるとき

+0

実際に使用している2つのタグ付きプログラミング言語はどれですか? –

答えて

1

利用前方宣言は、ヘッダは、構造体の詳細を知る必要はありません、tree.hでこれを試してみてください。

#ifndef tree 
#define tree 

#include "common.h" 
// #include "set.h" <-- don't include set.h 

typedef struct Set Set; 

/*Tree Structure*/ 
typedef struct 
{ 
    Set *set; 
    unsigned int setLength; 
    int vertexLength; 
    ... 
} TreeNode; 

set.hに:

typedef struct Set Set; 
struct Set 
{ 
    int combinationLength; 
    int* combination; 
} Set; 
+0

うわー、これは私の問題を解決!多くのありがとう<3 –

+0

しかし、set.hにあるメソッドを使用しているので警告が表示されました –

+0

@MohamadYassine警告は何ですか? – fluter

0

あなたが書く:

#define tree 

とラ同じファイル内TER:

int get_number_of_leaves(Tree *tree); 

のでtreeは、マクロ名と変数の両方です。あなたがエラーを受け取ったことは驚くことではない!

なぜマクロ名には小さな文字を使用しないでください。

関連する問題