1

The code is compiling fine in VS2015 but in VS2019 code is throwing errors for CPPUNIT. Is it not supported in C++17 std? if not how to resolve these error:

Code:

    class CAbcTestCase : public CppUnit::TestCase
    {
    
    CPPUNIT_TEST_SUITE(CAbcTestCase);       
    
            CPPUNIT_TEST(AbcThruRMB);
            CPPUNIT_TEST(AbcMultiThruRMB);
            CPPUNIT_TEST(AbcFolderThruRMB);
            CPPUNIT_TEST(AbcUseFileThruRMB);
            ........
            ........
            //CPPUNIT_TEST(Abc_UpdateRegistry);
            CPPUNIT_TEST(Abc_Initialize);
        **CPPUNIT_TEST_SUITE_END();** // *This line has all the below mentioned errors*
}

CPPUNIT error:

Error C2039 'auto_ptr': is not a member of 'std'

Error C2065 'auto_ptr': undeclared identifier.

Error C2660 'CHistoryTestCase::suite': function does not take 1 arguments

Error C2275 'CppUnit:: TestSuite': illegal use of this type as an expression

Error (active) E0135 namespace "std" has no member "auto_ptr"

6
  • 2
    As described in the documentation of std::auto_ptr: it was deprecated in C++11, and was removed in C++17. Commented Jul 23, 2020 at 10:47
  • stackoverflow.com/a/48883091/11683?
    – GSerg
    Commented Jul 23, 2020 at 10:48
  • Those errors complain about auto_ptr, not the CPPUNIT macro directly. auto_ptr was deprecated and finally removed, replaced by unique_ptr. I suspect you're using a very old version of pcpunit, or your macros need updating Commented Jul 23, 2020 at 10:48
  • But why it is showing error at CPPUnit ? i have not included auto_ptr anywhere in the code..so how can i change.
    – User1714
    Commented Jul 23, 2020 at 10:56
  • Try using a more recent fork of cppunit like freedesktop.org/wiki/Software/cppunit, the sourceforge version hasn't been maintained since 2008 Commented Jul 23, 2020 at 10:58

1 Answer 1

1

Does std C++17 does not support CPPUNIT?

You've got the relation backwards. It is the program that has to be compatible with the programming language. So, the question is, does (this version of) CPPUNIT work with C++17?

Based on the error, if CPPUNIT does indeed use std::auto_ptr, then it isn't C++17 compatible, because that class was removed from the standard library.

That said, perhaps it is possible that it is one of the test cases that is incompatible with C++17 rather than CPPUNIT itself? Also note that according to wikipedia, CPPUNIT "has been forked several times". If it is the framework that is incompatible, then the problem may be solvable by using a fork that is actively developed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.