我在C中有相关的标头,这给了我错误。我该如何删除?

穆罕默德(Mohamad Yassine)

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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

我想从列表中删除所有点,但我的程序给了我错误。我该如何解决

如何展示广告,这给了我这个错误

我想从Realm数据库中删除数据,但这给了我错误

我无法单击带有硒的元素,这给了我错误元素不可交互

具有相同名称的多个标准标头-包含哪个标头,我该如何更改?

为什么我在请求中有 http 405 错误,我该如何使用 api?

我无法安装 Urllib 模块所有其他模块都可以轻松安装,但这给了我错误

“java.lang.NullPointerException”错误(错误详情,文章中有)我该如何解决?

我没有503标头,现在Google显示“正在维护的网站”。如何将其删除?

即使我已经包含了相关的C库和标头,也会出现未知类型名称'size_t'的错误

我正在尝试统一构建游戏,但这给了我一个错误

在 Spring 的测试类中,该请求给了我 404 错误

该程序给了我一个循环导入错误,但仍然有效

我如何使我的所有标头元素都通过Nginx到达我的节点js API

我在C中的代码给了我很多错误

如何在没有标头的情况下将boost :: asio用于TCP协议,该标头不会告诉我消息的大小?

ifelse() 给了我错误的输出

他如何知道我的请求标头?

我的不和谐音乐bot播放音乐很好,并且1天后,没有任何变化,这给了我一个错误

Symfony 3 给了我 500 错误,没有错误

为什么这给我一个错误?我该如何修复它(上下文错误)

斐波那契-为什么这给了我错误的计算?

尝试在Python3中将fancyURLopener用于PDF,但这给了我DeprecationWarning错误

无法识别错误推理 - 与 ArrayList 和 FOR 循环相关,我该如何修复我的代码?

我在R中有一个因素列。我试图将其删除,但我不断收到错误消息。如何删除R中的因子列?

在forms.py中,当我将“ to_field_name”设置为多个列名时,这给了我错误

带有 Android 的 Proguard 给了我 JNI 错误

无法弄清楚为什么这给了我TypeError

我该如何解决“将标头发送到客户端后无法设置标头”