简体   繁体   English

在结构类型之后声明的变量中的变量重新定义

[英]Variable redefinition in variable declared after struct type

I'm writing a simple program, and had to write the following struct ( into my "node.h" file ): 我正在编写一个简单的程序,并且不得不将以下结构(写入我的“ node.h”文件中):

#ifndef NODE_H
#define NODE_H

struct _noh
{
    int peso;
    int altura;
    struct  _noh* filho[2];
} base = { 0, 0 ,{ &base, &base } }, *nnil = &base;

typedef struct _noh noh;

noh* novonoh(int valor);

#endif

I have added the node.h file into my node.c file with the implementation of novonoh(int valor) function, when I add the "node.h" file into my main.c file, I got this error: 我已经通过novonoh(int valor)函数的实现将node.h文件添加到我的node.c文件中,当我将main.c文件添加到“ node.h”文件时,出现了以下错误:

1>main.obj : error LNK2005: _base already defined in node.obj 1> main.obj:错误LNK2005:_base已在node.obj中定义

1>main.obj : error LNK2005: _nnil already defined in node.obj 1> main.obj:错误LNK2005:_nnil已在node.obj中定义

What is wrong with the code to get this error ? 获取此错误的代码有什么问题?

How I can solve this ? 我该如何解决?

我解决了这个问题,只是从标头中删除了base和nnil变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM