0
votes

I'm writing a simple program, and had to write the following struct ( into my "node.h" file ):

#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:

1>main.obj : error LNK2005: _base already defined in node.obj

1>main.obj : error LNK2005: _nnil already defined in node.obj

What is wrong with the code to get this error ?

How I can solve this ?

1
Don't define variables in header files. - Kerrek SB

1 Answers

1
votes

I solved the question, just removing the base and nnil variables from header.