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"
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.
Related
Environment:
Framework: Qt 5.12.9
Compiler: MSVC 15.9.28307.1234 (x64)
Debugger: CDB 10.017763.132 (x64)
Standard: C++11
Editor: Qt Creator 4.12.2
OS: Win10 Enterprise 1809
I want to develop an application that can be expanded through plug-ins. Therefore I created a standard library project where I want to define the plug-in interfaces. This library should then be consumed by the main application and its plug-ins.
I read about the Qt plug-in system on the official websites and sought help by duckduckgo-ing, but I'm stuck with these following errors:
vccplugin.h:16:32: error: expected parameter declarator
vccplugin.h:14:23: note: expanded from macro 'VccPlugin_iid'
vccplugin.h:16:32: error: expected ')'
vccplugin.h:14:23: note: expanded from macro 'VccPlugin_iid'
vccplugin.h:16:20: note: to match this '('
vccplugin.h:16:1: error: C++ requires a type specifier for all declarations
Build Issue: C2059: syntax error: 'string'
This is the code:
#ifndef VCCPLUGIN_H
#define VCCPLUGIN_H
#include "VccPluginInterface_global.h"
class VCCPLUGININTERFACE_EXPORT VccPlugin
{
public:
VccPlugin();
~VccPlugin();
void DoeEenTwuk();
};
#define VccPlugin_iid "automation.general.vcc.interface"
Q_DECLARE_INTERFACE(VccPlugin, VccPlugin_iid);
#endif // VCCPLUGIN_H
Also note, I have little experience in both C++ and Qt.
Any help very appreciated,
thanks
I have found the issue. The problem is that the compiler couldn't find the macro, so all I had to add was:
#include <QtPlugin>
Since Q_DECLARE_INTERFACE is defined in QtPlugin. Your example didn't import QtPlugin but was probably imported implicit by another import, probably QMainWindow.
It would have been simpler if I got an error like: "Could not find symbol Q_DECLARE_INTERFACE" if you ask me. Especially since I'm rather blue in this topic.
Thanks for your support #NgocMinhNguyen and others
I'm trying to build a C++ OpenGL application in xCode 6.1.1 on OSX 10.9.5 for a Mac version of a game I'm writing. I've managed to achieve this before with prior versions of xCode (and presumably GCC) but I'm really struggling to get it to build.
I created the project as a Command Line Tool and added the required files and preprocessor macros to select the appropriate libraries but I'm getting compile errors with regards to standard libraries.
If I use libc++ (LLVM C++ standard library) I get errors in algorithm such as:
Use of undeclared identifier of 'numeric_limits'
No member named 'digits' in the global namespace
No member named 'max' in the global namespace; did you mean simply 'max'?
Use of undeclared identifier 'uint32_t'
If I use libstdc++ (GNU C++ standard library) I get significantly less errors:
stl_bvector.h: Use of undeclared identifier 'CHAR_BIT'
stl_tempbuf.h:
No type named 'return_temporary_buffer' in namespace 'std' (x2)
No template named 'get_temporary_buffer'; did you mean '::std::_Temporary_buffer'?
Too few template arguments for class template '_Temporary_buffer'
So it seems the STD libraries have got screwed up but I don't understand how and if that is the case, why hasn't this been reported more? So I'm assuming I must be doing something wrong but I can't work out why...
So in my CSE course we are given a header file to use right now for our programs that we're writing.
Unfortunately I can't get terminal to compile using that header, it gives quite a few errors (compiling with just 'g++'). Also, when I'm at my university and I'm using PuTTY I get the same errors while using this header. However, I don't get the errors when I compile with 'g++ -std=c++14'.
I've tried compiling with this command on terminal on my mac, but it says it doesn't recognize the c++14 part.
dhcp-10-202-147-243:hw1pr1 Admin$ g++ -std=c++14 hw1pr1.cpp
error: invalid value 'c++14' in '-std=c++14'
Any help on how I could get this to work would be greatly appreciated. Hopefully this all made some sort of sense.
Here's the error I get when I compile with the header file I'm talking about in terminal with just g++.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ext/hash_map:212:5: warning:
Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>
[-W#warnings]
# warning Use of the header <ext/hash_map> is deprecated. Migrate to ...
^
In file included from read_first_name.cpp:1:
./std_lib_facilities_4.h:43:20: error: no matching function for call to object
of type 'hash<char *>'
return hash<char*>()(s.c_str());
^~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ext/__hash:39:12: note:
candidate function not viable: 1st argument ('const value_type *'
(aka 'const char *')) would lose const qualifier
size_t operator()(char *__c) const _NOEXCEPT
^
In file included from read_first_name.cpp:1:
./std_lib_facilities_4.h:112:8: warning: comparison of unsigned expression < 0
is always false [-Wtautological-compare]
if (i<0||size()<=i) throw Range_error(i);
~^~
./std_lib_facilities_4.h:118:8: warning: comparison of unsigned expression < 0
is always false [-Wtautological-compare]
if (i<0||size()<=i) throw Range_error(i);
~^~
3 warnings and 1 error generated.
This error doesn't happen and the program will compile fully when I use PuTTY and 'g++ std=c++14'
There's lots of change between C++ standards, so what is valid in one revision need not be in another.
g++ defaults to -std=gnu++98 for C++, which is the decades old C++98-standard enhanced with GNU extensions (most of which are conformant).
Choose the proper revision: -std=c++1y -pedantic is a very close approximation to C++14.
What changes introduced in C++14 can potentially break a program written in C++11?
Looking at what you say you're having to use and the name format of that .cpp file, I think I'm in the same class. A year later, looks like, but here's my solution for archive's sake:
The std_lib_facilities.h header comes with the Bjarne Stroustrup textbook, "Programming: Principles and Practices Using C++". For those unaware, Bjarne Stroustrup invented C++ (he has a pretty good idea what he's talking about). Incidentally, the book is a fantastic way to learn C++, if one takes the time to actually read it. The std_lib_facilities.h header is just a convenient header file for beginners in C++, containing links to all the major standard libraries used in the textbook, as well as some helper functions that help account for potential mistakes or errors, or are just convenient for learning (such as an error() function that handles simple exception throwing for the student, or adding an "out of bounds" check for vectors). It's ultimately just a way to allow students to hop right into code without having to learn specifics about the header.
Stroustrup keeps updated with C++ and thus includes several libraries that require the c++11 standard. The CSCE department wants its students (at least in this early class) to connect to the department's Unix system and compile from there, in order to avoid confusion with downloading and updating compilers.
I happened to already have had a couple C++ classes beforehand, and thus already had g++ set up on my Ubuntu laptop. I avoided including the std_lib_facilities for as long as possible since I was getting the same error as Topic Creator Joe, where g++ didn't recognize the "c++11" part (manually including the required libraries worked fine until we had to use a class from the textbook that used one of the header's helper functions) . Eventually, I found a help topic online that advised me simply to update my g++ compiler to 4.7 or higher, since 4.6 and lower doesn't have support for C++11 (or, of course, C++14). It was oddly rather involved compared to updates one might be used to on Mac or Windows, and I doubt the exact process would apply, but that is (was?) likely the problem: it's just an older version of g++, and it needs an update to compile C++11 and later. I recommend searching for ways to update g++/gcc for Mac.
Should, y'know, anyone else with this problem stumble upon this and not have their problem solved yet.
I am trying to compile boost under iOS, but every time I try to launch my project errors occurs like this:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/c++/4.2.1/bits/c++locale.h:79:28: No member named 'vsnprintf' in namespace 'std'; did you mean 'vsprintf'?
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/c++/4.2.1/bits/c++locale.h:79:60: Too many arguments to function call, expected 3, have 4
I think that the main reason is compiler, I try to change some settings and play with compiler but every time new errors occurs, so here are my current settings for compiler,
C Language Dialector - C99[-std=c99]
C++ Language Dialector - C++98[-std=C++98]
C++ Standard library - libstdc++
Boost version is 1.44.0,
XCode version is 4.5
Anybody knows how I must configurate my project to compile boost under iOS ?
According to this reference page for vsnprintf() it was introduced in C++11, so instead of -std=C++98 try -std=C++0x (however, the compiler may not support all features introduced in C++11).
When I create a new msvc project and try using the type uint8_t I get the following compile error:
error C2065: 'uint8_t' : undeclared identifier
Is there a project setting or predefined include that I can use? I'd prefer not to typedef values explicitly.
You need to include <stdint.h> (or <cstdint>), which is not available prior to VS2k10 as far as I can tell.
If you're using an older version of cl you can search for an open source implementation that meets your licensing requirements, or if none exist you'll have to supply the typedefs yourself.
Boost library have some definitions for this. But it's only for C++.