0

I got the following error:

In file included from generated/tandembiginteger.cpp:2:
generated/tandembiginteger.h:26: error: redefinition of `const int tandem::TandemMessageType_TandemBigInteger'
generated/tandembiginteger.h:26: error: `const int tandem::TandemMessageType_TandemBigInteger' previously defined here
generated/tandembiginteger.h:26: confused by earlier errors, bailing out

as you can see the redeclaration and the "previously" declared places are the SAME. What kind of an error is this ? How to solve it ?

Chani
  • 4,549
  • 11
  • 50
  • 84
  • 2
    Where's the source? From the error messages alone one cannot conclude the places are the same, only that they are on the same line. – chill Dec 03 '13 at 10:33
  • 1
    Does this header file have an include guard? – Hulk Dec 03 '13 at 10:37
  • @chill you are correct, that could have been the case. But it isn't. Infact there is only a single instance of `const int tandem::TandemMessageType_TandemBigInteger` in the entire codebase – Chani Dec 03 '13 at 10:38
  • @chill Also, are you saying taht it is ok to have multiple header files with same name ? taht compiles ? – Chani Dec 03 '13 at 10:38
  • @Hulk It had a header guard. But a faulty one ! someone made a copy past error ! it was like `#ifndef X_H_ #define Y_H_ ` :O thanks for mentioning guards :) – Chani Dec 03 '13 at 10:42

1 Answers1

3

I think you just need to use include guards.

Here's a discussion on SO about it: #pragma once vs include guards?

Community
  • 1
  • 1
vipw
  • 7,358
  • 4
  • 22
  • 45
  • It had a header guard. But a faulty one ! someone made a copy past error ! it was like #ifndef X_H_ #define Y_H_ :O thanks for mentioning guards :) – Chani Dec 03 '13 at 10:43
  • 1
    Which is exactly why #pragma once is considered safer. :) – vipw Dec 03 '13 at 10:43