CATCH error: redefinition of 'autoRegistrarXX'

62 views
Skip to first unread message

Mariano Lizarraga

unread,
Feb 4, 2015, 12:33:15 PM2/4/15
to catch...@googlegroups.com
Hello All,
I have this weird error in CATCH that I can't figure out. I've searched the web and apparently I am the only one having it so it seems like it is an error of how I am using CATCH.

I have a single testSuite file as follows, which I compile with g++:

#include "conversionsTest.h"
#include "mpu6000Test.h"
#include "navSupportTest.h"
#include "gpsPortTest.h"
#include "gpsUbloxTest.h"
#include "apUtilsTest.h"

#define CATCH_CONFIG_MAIN

where each *test.h file has its own TEST_CASEs and SECTIONs. There is a moment that if I include another test file, I get this error about redefinition of an autoregistrarXX and it seems like the renaming of the CATCH macros is failing. I'll attach the compiler error at the end but my main question is: Is this how CATCH is supposed to be used when having multiple test files? 

Here is the compiler error I get, any help is greatly appreciated.

Thanks!

==============
In file included from ./testSuite/apTestSuite.c:15:
./testSuite/gpsPortTest.h:52:1: error: redefinition of 'autoRegistrar52'
TEST_CASE ("There are data in the buffer"){
^
../Catch/single_include/catch.hpp:8945:30: note: expanded from macro 'TEST_CASE'
    #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
                             ^
../Catch/single_include/catch.hpp:540:35: note: expanded from macro 'INTERNAL_CATCH_TESTCASE'
        namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_...
                                  ^
../Catch/single_include/catch.hpp:55:44: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME'
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
                                           ^
../Catch/single_include/catch.hpp:54:55: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
                                                      ^
../Catch/single_include/catch.hpp:53:56: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE2'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
                                                       ^
<scratch space>:197:1: note: expanded from here
autoRegistrar52
^
./testSuite/conversionsTest.h:52:1: note: previous definition is here
TEST_CASE("Comparing the conversions between bytes and Short datatypes", "[datatypes]"){
^
../Catch/single_include/catch.hpp:8945:30: note: expanded from macro 'TEST_CASE'
    #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
                             ^
../Catch/single_include/catch.hpp:540:35: note: expanded from macro 'INTERNAL_CATCH_TESTCASE'
        namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_...
                                  ^
../Catch/single_include/catch.hpp:55:44: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME'
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
                                           ^
../Catch/single_include/catch.hpp:54:55: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
                                                      ^
../Catch/single_include/catch.hpp:53:56: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE2'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
                                                       ^
<scratch space>:205:1: note: expanded from here
autoRegistrar52
^
In file included from ./testSuite/apTestSuite.c:15:
./testSuite/gpsPortTest.h:52:1: error: redefinition of '____C_A_T_C_H____T_E_S_T____52'
TEST_CASE ("There are datas in the buffer"){
^
../Catch/single_include/catch.hpp:8945:30: note: expanded from macro 'TEST_CASE'
    #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
                             ^
../Catch/single_include/catch.hpp:541:21: note: expanded from macro 'INTERNAL_CATCH_TESTCASE'
        static void INTERNAL_CATCH_UNIQUE_NAME(  ____C_A_T_C_H____T_E_S_T____ )()
                    ^
../Catch/single_include/catch.hpp:55:44: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME'
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
                                           ^
../Catch/single_include/catch.hpp:54:55: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
                                                      ^
../Catch/single_include/catch.hpp:53:56: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE2'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
                                                       ^
<scratch space>:197:1: note: expanded from here
____C_A_T_C_H____T_E_S_T____52
^
./testSuite/conversionsTest.h:52:1: note: previous definition is here
TEST_CASE("Comparing the conversions between bytes and Short datatypes", "[datatypes]"){
^
../Catch/single_include/catch.hpp:8945:30: note: expanded from macro 'TEST_CASE'
    #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
                             ^
../Catch/single_include/catch.hpp:541:21: note: expanded from macro 'INTERNAL_CATCH_TESTCASE'
        static void INTERNAL_CATCH_UNIQUE_NAME(  ____C_A_T_C_H____T_E_S_T____ )()
                    ^
../Catch/single_include/catch.hpp:55:44: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME'
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
                                           ^
../Catch/single_include/catch.hpp:54:55: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
                                                      ^
../Catch/single_include/catch.hpp:53:56: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE2'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
                                                       ^
<scratch space>:211:1: note: expanded from here
____C_A_T_C_H____T_E_S_T____52
^
In file included from ./testSuite/apTestSuite.c:16:
./testSuite/gpsUbloxTest.h:52:1: error: redefinition of 'autoRegistrar52'
TEST_CASE ("Compute the NMEA sentence checksum"){
^
../Catch/single_include/catch.hpp:8945:30: note: expanded from macro 'TEST_CASE'
    #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
                             ^
../Catch/single_include/catch.hpp:540:35: note: expanded from macro 'INTERNAL_CATCH_TESTCASE'
        namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_...
                                  ^
../Catch/single_include/catch.hpp:55:44: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME'
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
                                           ^
../Catch/single_include/catch.hpp:54:55: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
                                                      ^
../Catch/single_include/catch.hpp:53:56: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE2'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
                                                       ^
<scratch space>:56:1: note: expanded from here
autoRegistrar52
^
./testSuite/conversionsTest.h:52:1: note: previous definition is here
TEST_CASE("Comparing the conversions between bytes and Short datatypes", "[datatypes]"){
^
../Catch/single_include/catch.hpp:8945:30: note: expanded from macro 'TEST_CASE'
    #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
                             ^
../Catch/single_include/catch.hpp:540:35: note: expanded from macro 'INTERNAL_CATCH_TESTCASE'
        namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_...
                                  ^
../Catch/single_include/catch.hpp:55:44: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME'
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
                                           ^
../Catch/single_include/catch.hpp:54:55: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
                                                      ^
../Catch/single_include/catch.hpp:53:56: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME_LINE2'
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
                                                       ^
<scratch space>:205:1: note: expanded from here
autoRegistrar52
^
3 errors generated.

==============
Reply all
Reply to author
Forward
0 new messages