3
votes

Question:

In the GCC/MinGW folder tree, there are duplicates of some header file names, in folders: ssp, ext, tr1; parallel, ext, bits, and experiemental ...

Should explicit "include" directives for these folders be avoided in production code--as a best practice?

OR, is there documentation online, regarding the legitimate scenarios these folders should be explicitly used in #include statements?

Notes: 1. SSP: (Stack Smashing Protector) 2. tr1: Technical Report 1, (Stack Link), seems deprecated.

Tool Chain:

C++ 11, and C++ 14:

Eclipse CDT, using the Clang ToolChain, with Google Test API, and MinGW (5.1).

At the time of this post, Clang's LibC++ is not built for Windows yet, so using the MinGW : Posix, SEH, X86_64, bundle.

<stdio.h> Folders:

  1. include/stdio.h
  2. include/c++/tr1/stdio.h
  3. lib/gcc/x86_0w64-mingw32/5.1.0/include/ssp/stdio.h

<algorithm> Folders:

  1. include/c++/algorithm
  2. include/c++/experimental/algorithm
  3. include/c++/ext/algorithm
  4. include/c++/parallel/algorithm
1
It's not very clear what you are asking... FWIW, I've always seen stuff being included explicitly from those locations, e.g. <bits/c++config.h>, <ext/bitmap_allocator.h>, <tr1/cmath> and the like, never adding one of those directories directly to the include search path. Notice that, as far as I always understood, the bits directory should be mostly left alone, as it contains implementation-version specific stuff (not necessarily stable API-wise).Matteo Italia
Thank you. As you point out, I have observed this as well. But, I will clarify the question: "Should these be avoided as a best practice? Or, what are the scenarios they should be utilized?"elika kohen
As said above: bits should be left alone; the others can all be used, as long as you are willing to accept that you are depending from libstdc++ and not standard C++ alone (an exception should be made for tr1, which should be standard, and some other stuff; for details, see gcc.gnu.org/onlinedocs/libstdc++/manual/using_headers.html ).Matteo Italia
@MatteoItalia (A.) Can you post that last comment as an answer, and I can copy/paste specific answers from that file into it? (Or I can post the answer). (B.) It certainly addresses the issue with tr1; and ext, and parallel to a certain extent. (C.) The document omits discussion on ssp, which I have another resource for. (D.) Still need a reference to understand what the exceptional circumstances around "bits", and "experimental".elika kohen
Since the mingw-w64 project on sourceforge.net is moving to mingw-w64.org i suggest to use mingw-w64.orgPOQDavid

1 Answers

2
votes

(moving/expanding from the comments)

I've always seen stuff being included explicitly from those locations, e.g. <bits/c++config.h>, <ext/bitmap_allocator.h>, <tr1/cmath> and the like, never adding one of those directories directly to the include search path. Notice that, as far as I always understood, the bits directory should be mostly left alone, as it contains implementation-version specific stuff (not necessarily stable API-wise). I cannot find explicit documentation of this, but the general structure of the library (with standard public headers in the root that include their bits counterparts) seems to suggest so.

Should these be avoided as a best practice? Or, what are the scenarios they should be utilized?

Excluding bits, the others can all be used, as long as you are willing to accept that you are depending from libstdc++ and not standard C++ alone, as specified in the documentation at http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_headers.html:

The "less nonstandard" stuff is what you find in tr1; it comes from the C++ TR1 which, is not a "real" standard, but recommendations for stuff to be included in the then-upcoming C++11 standard; before 2011 you could use it and expect some grade of interoperability with other compilers, today you can safely ignore it and just use C++11 (which is actually standardized and differs quite a bit in some details).

All ext are libstdc++ extensions, some are stuff that comes from the SGI STL, some are newer developments; it's not impossible that some of them will be included in some standard C++ proposal, but in that case they'll probably move somewhere else.

The parallel directory contains parallel implementations of some of the classic STL algorithms (details here); again, IIRC there is a proposal to standardize them, but as above I expect them to move somewhere else in case they are standardized, since rarely the standardization leaves proposals intact, and they'll need a way to let old programs run fine with the old headers/semantics.

experimental contains stuff for the new experimental Technical Specifications (the concept is similar to TR1), that should graduate to the "real" standard library when the new standards will be released; at the moment in my gcc 4.9.2 installation I can only find string_view and optional in there, but some other stuff should come; personally, as with tr1, I would wait for the tide to settle in the new standard before employing these headers in production code, because, as they are, they are both still something of a moving target, and the code quality is not on the par with the rest of the library (it's still experimental stuff, as the name says).

The ssp folder contains Stack Smashing Protector stuff. From OSDev, (Link):

Compilers such as GCC enables this feature if requested through compiler options, or if the compiler supplier enabled it by default. It is worth considering enabling it by default if your operating system is security conscious and you provide support.