Is there unit tests for STL containers? [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Is there ready unit tests for testing if STL containers are working correctly, something that was used by compiler creators?
I'm making a simple port of the STL in C and need to test the data structures and thought that STL unit tests already existed, but didn't find anything

Is there unit tests for STL containers?
STL does not exist anymore. Read the C++11 standard n3337 and see this C++ reference website. Consider also using Boost.
Both recent GCC and recent Clang provide testsuites for the standard C++ containers library, whose implementation is practically tied to the compiler (because of compiler optimizations)
I'm making a simple port of the STL in C
Then look -at least for inspiration- into Glib (from GTK) and SGLIB. I tend to think that you could use one of them. Given the complexity of the standard C++ library, I believe you won't be able to make from scratch in just a few weeks a simple port of it to C if you care about efficiency. Look also into MILEPOST GCC and read this paper then Artificial Beings: the conscience of a conscious machine ISBN:9781848211018 for some interesting insights.
Otherwise, be sure to read Introduction to algorithms
Notice that with some care, you usually can write in C++ a library callable from C (use extern "C" appropriately and systematically). A good example is of course libgccjit (which you could consider using, for some partial evaluation based approaches: you might generate specialized machine code suited to particular instances of your problems).
If you code your generic container library in C, consider using Frama-C on it, and with a recent GCC, compile it with all warnings and static analysis options. You might even consider writing your GCC plugin to check that users of your library are using it correctly.
See also the European DECODER project.

Related

How to read/interrogate a filesystem and file structure [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
As a first time programming using vi with a raw Linux terminal in C++, what is the simplest way to recurse through a filesystem and get results such as file size, date, directory date etc?
I imagine I'm missing a library or two that would handle this pretty cleanly which would be great to know. Even better would be knowing where to find a solid reference for the basics like this.
If you have a modern compiler you can use std::filesystem:
https://en.cppreference.com/w/cpp/filesystem
Otherwise you can use boost::filesystem, which is very similar but non standard:
https://www.boost.org/doc/libs/1_67_0/libs/filesystem/doc/index.htm
Boost is a collection of libraries with various purposes and a focus on quality. Boost libraries regularly end up in the new C++ standards so it's good thing to learn.
You might consider (on Linux at least) to use nftw(3). You could use opendir(3) + readdir(3) + closedir with stat(2) (and nftw is using all these). See also syscalls(2) (and read some Linux programming book, perhaps the old ALP). Notice that on Linux (and POSIX systems), the operating system API is in C, not in C++.
Of course, you might use the C++ functions given in f4's answer (they are are based on functions above).
And you could use C++ frameworks such as boost, poco, Qt (also using the functions above).

What are the compromises with using Xojo for cross platform development? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Much of the cross-platform development topics on SO seems to be 6 to 9 years old. Anyone have recent experience with Xojo? Can it be used to quickly deploy UI on top of C++ generated linked libraries on macOS and Windows? How does that work on iOS? What are the limitations of this tool?
I have no experience with iOS deployment with Xojo but used Xojo for quite a few x-platform projects (Mac/Win/Linux) where I also access self-written C code, in iBored for instance.
Overall, I like Xojo better than Qt or Java for designing and deploying apps with a GUI. Xojo adheres closer to the UI specifics, IMHO. You'll have a harder time finding help, however, since the community is rather small.
To access C++ code you need to write yourself a C-level layer because Xojo does not provide an easy way to link to and use C++ objects. But interfacing plain function in any library (.dylib, .dll, .so) is super easy, and mainly involves writing the Xojo equivalent of a function declaration, and possibly add some structure definitions as well. You can pass all the simple datatypes (Int in all sizes, float, double, C and Pascal strings, even access raw memory via pointers) but will have to provide accessor functions for more complex data structures (array, dicts etc.) as Xojo's object manangement does not mix with that of C++ or other runtimes.
Xojo has been around for nearly 20 years now (formerly known as REALbasic) and is decent enough to rely on it.
OTOH, Xojo is closed source, and the company is rather slow (or even unable / unwilling) to fix issues - and you can't fix them yourselves, obviously. I had more than one case where I figured out how to fix a bug in their binary code, and they wanted to prohibit me from doing that, threatening to invalidate my license, while also not committing to providing a fix. If that worries you, I advise you to stay away from Xojo.

google test/mock vs boost vs catch support for c++14/c++17 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
The community reviewed whether to reopen this question 29 days ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I am evaluating which testing framework would be ideal for me.
The choice is among these three: google test, boost.test and catch.
I would like something robust that has not so many dependencies and that is able to support C++14/C++17 if needed.
Another question, do you know which framework big companies in the avionics/space fields use?
I would like something robust that has not so many dependencies and that is able to support c++14/c++17 if needed.
Google C++ test framework requirements mention:
A C++98-standard-compliant compiler
It works just fine with C++14, I personally use it. From the linked documentation you can see that it has no dependencies on external libraries (see section requirements).
Catch known limitations mention:
our desire to support C++98 compilers
It works just fine with C++14, I personally used it in a couple of projects at work. Catch is a header only library, it has no dependencies at all.
Boost C++ libraries usually perform compile-time detection of compiler support for the standards and features are enabled/disabled depending on the result.
As a rule of thumb, those libraries usually depend on some other libraries picked up from Boost itself.
do you know which framework big companies in the avionics/space fields use?
Often they require not only to write tests but also to have a code coverage estimation. There are a plenty of professional tools for that, few of them are for free and (at least, as long as I know) there doesn't exist a standard de facto for that.

Translating new C++ to old C++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
C++11 and C++14 introduce a lot of new features that make programmers' lives easier. However, in various environments (e.g. CUDA), support for the most modern C++ features may be weak or nonexistent.
Many of these features (e.g. auto, decltype, constexpr, variadic templates) do not add any challenges to code generation, and really only require a parser that understands the constructs. In principle, unless honestly new functionality (e.g. thread_local) is used, there could be a tool that takes C++14 code and converts it into something that could be built with something that only understands the C++03 language.
Does such a tool exist? (or are my presumptions way off base?)
AFAIK no such tool exist. Some C++ compilers (the original Cfront, and perhaps Comeau C++) generated C code.
You might customize GCC (e.g. using MELT) to translate the internal Gimple representation to a small subset of C++. This is a lot of work (and the emitted C++ won't be portable).
Maybe you should consider OpenACC

Policy based design in a real world open source project [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Can anybody point me to an open source C++ project(preferably not a lib), where policy based design is extensively used?
Well, I suppose that any C++ application using the STL containers (parameterized by an Allocator and, sometimes, a Comparator) extensively use Policy-Based design. It's been a corner stone of the STL even seen it saw the light at SGI.
The obvious one by Alexandrescu: Loki
It's being actively developed.
any project that is using boost :-) http://www.boost.org/community/generic_programming.html#policy
if you mean initiating policy-based objects, than it would be a lot of projects that use boost. For example, http://programmingexamples.net/wiki/CPP/Boost/BGL/DijkstraDirected
or you can look at big projects on github https://github.com/search?q=%23include+%3Cboost%2Fgraph%2Fgraph_traits.hpp%3E&type=Code&ref=searchresults
if you mean defining policy-based object, than most of the use cases would be libraries. The reason for that is that if somethings needs a lot of customization and can be generalized, it becomes a library (even if for internal use). If you just writing a straightforward program that doesn't need customization of objects and poly-morphism, than it wouldn't use much of policy-based design.
for those, you can also search on github, trying out some common policy-based syntaxes.
In my scientific work, I use boost's odeint library that relies on policies. When I code, i start with a specialized hamiltonian, than I generalize it with policies and it basically becomes a library that I use in many other projects.