Reputation: 1265
I have a project written in C++11. As C++11 is widely accepted, the project works well up to now, until I have to run it in a environment which not support C++11.
I have already used std::shared_ptr
, auto
, std::intializer_list
, nullptr
enum class
,chrono
, std::vector<int> x{1,2,3,4}
and many other C++11 technique everywhere in the project.
How can I move the big project in C++11 to C++98?
I apologize if it is a stupid problem, Thanks for your time.
Upvotes: 2
Views: 694
Reputation:
One solution is to try looking for C++ external libraries such as Boost and Qt, which could cover half of your requisites.
However some things are implementation-specific and upto you, such as the auto
keyword, which you may choose to not use. (In fact if your using a proper debugger cum IDE, you'll get to check even complex data types in an instance)
Another alternative to that is replacing auto
by templates, as pointed out here. (without boost)
Similarly, stuff like macros and variadic templates shouldn't be hard to cover.
Upvotes: 1
Reputation: 21
I had to do something similar, but my challenge was co convert it from C++17 to C which was present on customer CentOS 7 (they used custom CentOS Image, and we were not allowed to install any new packages).
What I did was to throw out step by step all dependencies which used C++ elements and replace them with C variants. It took some time but it worked. Also looked after some other solution, but I was not able to find any.
You could always rewrite shared pointer, vector etc. in C.
Upvotes: 2
Reputation: 163
Maybe not exactly what you ask but when I want to run code to another computer without support C++11 I will create docker with C++11 inside this computer. Hope this helps!
Upvotes: 1
Reputation: 13679
Decide about each piece separately.
If that platform can run at least a subset of boost
, you can probably just replace std::chrono
and std::shared_ptr
. You can also replace lambdas with BOOST_LOCAL_FUNCTION
Upvotes: 2