Questions tagged [c++03]
C++03 is an older revision of the C++ standard. The more recent revisions, C++11 and the current C++14, are still being adopted.
802
questions
0
votes
0
answers
44
views
Can't configure Visual Studio Code to use C++14 standard (C++03 standard is used even though I changed some settings)
I did a very simple app that works when I build and run it from the terminal by:
g++ -std=c++14 helloworld.cpp
./a.out
Now I'm trying to configure the Visual Studio Code to debug this app. I did:
...
0
votes
0
answers
60
views
WinAPI: repeatable check in a separate thread that notifies UI thread when check fails
My application has a separate thread that repeatably performs some check. If the check fails, the UI thread is notified (a MessageBox is displayed that requires user action what to do next).
...
1
vote
2
answers
78
views
How do I perform a narrowing conversion from double to float safely?
I am getting some -Wnarrowing conversion errors when doubles are narrowed to floats. How can I do this in a well defined way? Preferably with an option in a template I can toggle to switch behavior ...
1
vote
1
answer
56
views
How to use preprocessor IF on DEFINE that is an ENUM member?
I am struggling with this for a while now, and cant get it to work!
I have a preprocessor define for LOG_LEVEL which defines what logs my program should emit.
I Have a lot of LOG points, so ...
1
vote
1
answer
57
views
How can I run the custom version of C++03 in Xcode?
For a school assignment, I am required to use C++ version 03. I have a Mac, and I was told to use Xcode by my instructor.
After a bit of research, I found the place on where to change the version of C+...
2
votes
1
answer
198
views
How to set standard C++ 2003 in CMake
I'm looking for solution how to set standard of C++ to 2003 in cmake. I can find a lot of information how to do it on later versions like 11, 17 and so on. But for 2003 version I couldn't find it. ...
2
votes
2
answers
125
views
C++03 Replace Preprocessor Directives with Template Metaprogramming
I have a embedded C++03 codebase that needs to support different vendors of gadgets, but only ever one at a time. Most of the functions overlap between the several gadgets, but there are a few ...
0
votes
0
answers
110
views
Why is GCC complaining with Wstringop-overflow?
I have code which looks like this:
char* newChar = new char[strlen(inputCharArray)+1];
if (NULL == newChar) {
return;
}
strncpy(newChar, inputCharArray, strlen(inputCharArray));
newChar[strlen(...
0
votes
0
answers
26
views
C++ Trying to Find An Alternative Way to Implement Forward Declaration [duplicate]
I asked this question 2 days ago, but I had to fix some lines. So here my question again:
I have multiple classes and have written them in an order. First class has an enum, but I want to move it to ...
1
vote
0
answers
71
views
C++ Forward Declaration - Incomplete type is not allowed
I have multiple classes and have written them in an order. First class has an enum, but I want to move it to the class that is below all other classes. This is where problem begins. Since the last ...
0
votes
1
answer
34
views
not able to assign `boost::assign::list_of` to `static const std::vector`
I am using C++ 03, previously I have code:
static const std::vector<std::pair<uint16_t, uint16_t>> a = boost::assign::list_of(std::make_pair(1,1)) std::make_pair(2,2));
and it worked.
Now ...
3
votes
2
answers
105
views
How to determine the data type in a generic container searching function
I am mainly a C developer, but starting to use C++ more and more.
I have a templated function below which will search for values in STL containers of different types and do some processing.
I ...
2
votes
1
answer
75
views
How can I set up my class so it can't be inherited from in C++98/C++03?
Using C++98 (or C++03), how can a class (B) be defined, such that no objects can be instantiated from a class (D) deriving from B.
struct B {};
struct D : public B {};
D d; // this should result in a ...
3
votes
1
answer
175
views
Can I insert a vector to itself with std::vector::insert?
Is it allowed by the C++03 standard to append a std::vector to itself? I wonder if the source iterators can become invalid if v needs to reallocate memory. In my STL implementation, the old memory is ...
1
vote
0
answers
51
views
Check for the existence of a member function fails [duplicate]
I have some old codebase that still uses C++03. I am trying to write a template that evaluates to true if a class has a member function called some_function, to be used inside enable_if statements. I ...
-8
votes
4
answers
419
views
How to replace all newline characters except last character in C-string with something else using C or C++03 [closed]
Given a C-string (const char*), what is an efficient way to replace all newline characters ('\n') except the last character (if it exists) with a different character (say, '\r'). Some examples:
...
4
votes
1
answer
169
views
Is there any alternative for type alias in C++0x?
I want to create an alias arr for std::array<T, 32>.
template<typename T>
using arr = std::array<T, 32>;
However, it does not work on GCC 4.4.6 which supports only C++0x(without ...
0
votes
1
answer
115
views
Locally redefining the implementation of a global function in C++
I am writing some testing code for an existing C++ application by writing a file with a main() function and some helper classes, and linking it to the object files of the application's other classes. ...
1
vote
1
answer
88
views
C++ Generator for permutations with a twist (decreasing each position)
I'm no mathematician, so I don't know if there is terminology for this (I could not find it).
What I'm looking for is C++ code to generate all permutations, with repetition, but with a twist: the ...
3
votes
1
answer
225
views
copy elision in c++03
Copy-elision is, in some cases, mandatory in c++17, and permitted in c++11/14. This in particular concerns copy initialization.
For example, the following program
#include <iostream>
struct A
{
...
0
votes
1
answer
101
views
RAD Studio c++ template generic event blocker
I've been having problems with RAD Studio XE components triggering a cascade of events - like when component A in-code modification altered content of component B which triggered change in component C ...
1
vote
1
answer
121
views
NULL implicit pointer conversion causing ambiguous overload
Problematic C++03 code:
#include <cstddef>
struct Foo {
explicit Foo(const char *){}
Foo &operator=(const char *) {return *this;}
Foo &operator=(char) {return *this;}
};
int ...
0
votes
2
answers
83
views
Specifying enum size in C++0x
I have a doubt regarding non-scoped enums behavior in C++03. I have read multiple questions and articles on Stack overflow and other pages.
I am using C++0x standard and running on GCC 4.6.4
I am able ...
0
votes
0
answers
154
views
The cause of incorrect for loop entry
I have a simple for loop (though it is not the only component within the method) that is compiled with GNU 4.8.1.10 compiler with debugging option is off and optimization levels O-0, O-2 and O-3 ...
-2
votes
1
answer
61
views
Convert C++ 11 code map with pair into C++ 03 [closed]
how can i convert C++ 11 code map with pair into C++ 03
std::map<string, pair<CO3d*, DWORD>> Entities;
std::map<string, pair<CO3d*, DWORD>> Objects;
std::map<...
1
vote
0
answers
29
views
c++ 2008 convert double to string without making it into exponentials for big values of double/int [duplicate]
I am using following function to convert a double(mostly int) to string, it is doing good for values <1000000, but for >1000000 it is giving answers in exponential 1e+06 i want it to show full ...
1
vote
3
answers
114
views
Use a function pointer as template function type parameter?
#include <iostream>
#include <unordered_map>
#include <utility>
#include <typeinfo>
using namespace std;
class Handle{
public:
int val;
bool getAskPrice(int& ...
3
votes
2
answers
327
views
Difference in definition of null pointer in C99 and C++03
N2431 is the paper that introduces nullptr. It says:
The current C++ standard provides the special rule that 0 is both an integer constant and a
null pointer constant. From [C++03] clause 4.10:
A ...
0
votes
2
answers
604
views
Can we build in Visual Studio 2017 C++ and still be MISRA C++ compliant?
MISRA c++:2008 was published in 2008. It was written for C++03.
Does this refer to just the syntax of C++2003 standard or do have to use the compiler as well.
We have written our code base in VS2017 ...
1
vote
1
answer
374
views
How to build to ISO C++03 in Visual Studio 2017?
Visual Studio 2017 only shows the ability to build:
ISO C++14 Standard
ISO C++17 Standard
ISO C++ Latest Draft Standard
Is there a way to compile and build to ISO C++03 standard on VS2017?
We have ...
1
vote
0
answers
62
views
did a C++ code developed in VS 6.0 compile in VS 2015
I said yes I can, so I've a code developed in VS 6.0 (compile fine) I think it uses C++03 version.
So I migrated the whole code (dependence ...) and now I start the compilation.
The problem that I see ...
0
votes
1
answer
107
views
How to pass functions into boost::geometry::index::satisfies() without a lambda expression
So I am using Boost's R-tree for an optimized spatial search. The parameters of the query is a search center and a radius, so I would be using my own function to see if the distance between a given ...
1
vote
1
answer
105
views
Preprocessor: concat previous line number in the name of a structure
I know how to declare a struct where the name contains the current line number. The following code works as expected.
#define CREATE_NAME_CONCAT_(X, Y) X ## Y
#define CREATE_NAME_CONCAT(X, Y) ...
1
vote
1
answer
50
views
Writing partial unique_ptr for C++03 compiler which operates on common codebase with newer compilers
I need to write an implementation of unique_ptr for C++03 which would only absorb changes made in common codebase under other platforms where C++11 is enabled. Namely, it doesn't need to check ...
0
votes
1
answer
102
views
Looking for a pointer ignoring instruction when null
I use a monitoring class Progress. In a lot of functions, I update the progress if given. The progress variable is optional and given by pointer that could be null. A lot of part of my code look like ...
3
votes
1
answer
160
views
__cplusplus expanded minimum values
Am I right to understand that these are the minimum values of __cplusplus and that C++98 has the same value has C++03?
// C++ 98
#define __cplusplus 199711L
// C++ 03
#define __cplusplus 199711L
// C++...
0
votes
1
answer
101
views
Concatenate string and integer in c++ for reading multiple file in case of C++ 11 not supporting computer
I would like to hear if there is a solution to this problem. my computer does not support C++ 11 so I can not join string and integer by std::string to_string... instead, I used a string stream.
I ...
0
votes
0
answers
50
views
Inheritance from multiply inherited templated class ambiguity problem
I'm using Arm Compiler 5 (C++2003).
I have a problem which I couldn't name it, I currently call it multiply inherited templated mixing class ambiguity problem.
I have a very base class template ...
5
votes
1
answer
550
views
Boost bind and 'result_type': is not a member, c++03-friendly
The latest 16.6 update to Visual Studio 2019 removed std::plus::result_type, std::minus::result_type, and related typedefs. (They're deprecated in C++17 and removed in C++20.) A greatly simplified ...
0
votes
0
answers
364
views
What is the difference between clock_nanosleep and sleep_until?
I have been, for a while, successfully using the following scheme to put a thread to sleep for an amount of time given by intervalMs:
struct timespec tsCreate( long seconds, long nanoseconds )
{ /*...
4
votes
0
answers
413
views
error c2373 redefinition different type modifiers with a template class
I wrote a template Interval class that I would like to use as a container for an interval of numbers. Since I would like to iterate over the elements virtually contained in this class, I added a ...
6
votes
1
answer
332
views
C++11 feature std::map::at compiling on older versions of C++
The code below uses std::map::at which was introduced in c++11, however, while specifying an older version (I've tried -std=c++03, -std=c++0x and -std=c++98) in g++ and cmake, it still gets compiled. ...
2
votes
0
answers
58
views
Zero-initialization of "POD" indirect base-class through "non-POD" base-class
Consider the following snippet:
extern "C" {
#include "POD.h" // Defines struct POD;
}
template<class Base>
struct non_copyable : Base
{
non_copyable() {}
private:
non_copyable(...
-2
votes
2
answers
68
views
Why is multiple variable definition across different source files a problem, but multiple class definition across different sources is not
I am currently learning C++ (more precisely C++03) at uni, and I came across the initialization of static members. Non-constant static members should be declared inside the class, but defined outside. ...
2
votes
2
answers
162
views
Is pow(x,p) faster when the exponent is an integer?
In a code using pow(double x, double p) (a big part of the cases have p = 2.0) I observed than the execution of my code is clearly faster when p = 2.0 than when p = 2.000000001. I conclude that, on my ...
0
votes
1
answer
42
views
Is it is possible to construct container and filled data into it in one line using C++03?
Suppose I have a Container.
template<typename Type>
class Container
{
public:
Container(int size_)
{
size=size_;
data = new Type[size];
}
~Container()
{
...
2
votes
2
answers
78
views
How to fill data into container at once without temp variable in C++03
Suppose I have a Container.
template<typename Type>
class Container
{
public:
Container(int size_)
{
size=size_;
data = new Type[size];
}
~Container()
{
...
2
votes
0
answers
88
views
using curly braces to construct a object not using initializer_list
There is a Container in my project.
I usually construct the object using curly braces, for example: Container x{1,2,3}.
It works well using std::initializer_list under C++11.
However, when I ...
-1
votes
1
answer
76
views
timespec_get functionality for C++03
I have the following code working on C++17, but I need the same functionality in C++03. How can I accomplish this?
return timespec_get(ts, 0) == 0;
1
vote
1
answer
535
views
Compiling with -std=c++03 not detected
I am compiling this simple code as g++ main.cpp -o main -std=c++03
#include <vector>
int main(){
std::vector<int> array;
std::vector<int> array2 = { 9, 7, 5, 3, 1 };
}
And ...