tree.h文件:
#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,对于set同样如此。我应该在common.h文件中包含所有字段吗?
当您需要在另一个头文件中引用该结构时,请使用前向声明,而该头不需要了解该结构的详细信息,请在以下方法中进行尝试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;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句