Reputation: 2025
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 ?
Upvotes: 0
Views: 30
Reputation: 2025
I solved the question, just removing the base and nnil variables from header.
Upvotes: 1