This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Standard Template Library (STL)

Other Parts Discussed in Thread: TMS320C6657

Hello

I work with TMS320C6657 EVM, with CCS5.4, SYS/BIOS 6.35 and c6000_7.4.2 compiler.

I want to use STL, C++ Standard Template Library (map,vector, etc..).

Is the compiler supports STL?

I found the file "stl.h" in the compiler include library, but if I include it in my project this causes a lot of errors (like identifier "const_iterator" in undefined).

Thank you

Yossi Regev 

  • Hi Yossi,

    Moved your thread to Compiler forum to get appropriate response.

    Thanks. 

  • The compiler supports the full C++ language, including the library.  And the standard C++ library includes most (all?) of STL.

    I do not know the purpose of the header file <stl.h> .  It is not required by the standard.  It some sort of extension.  It is not documented in any TI manual.  The authoritative book on C++ library anything is The C++ Standard Library by Josuttis.  I have a copy, and it makes no mention of <stl.h> .  For me, that is enough to say you don't need to know about it.

    You can certainly use C++ STL features such as map and vector.  The relevant header files are (no surprise here) <map> and <vector> .

    Thanks and regards,

    -George

  • I include the header file <map>, but when I try to write something like this:

    typedef struct{

         int A;

         int B;

    }STRUCT_AB;

    typedef map<char,STRUCT_AB> AB_MAP;

    I get an ERROR "#918 map is not a template".

    What I need to do to solve this error?

     

     

  • Yossi,

    I had this problem too at first, and I am trying to remember how I fixed it. 

    Did you check to see that the build option is set for C++?  --cpp_default

    And I also had to include the stl library in a certain order, before most of the TI files.  In addition, there are some TI files that can only be compiled in C and you have to put compile time options around them.  For example:

    extern "C"
    {
    #include "ti_dsplib.h"
    }


    Lastly, although I don't know your entire goal, I feel compelled to tell you that I spent the better part the summer messing around with an algorithm written with the STL libraries.  It was a mess and in the end, I had to re-write the algorithm without STL.  It was difficult to get it to work with multi-core since the STL libraries use "new" as their default allocator.  Once I finally figured that out, it was way too slow because STL allocates and deallocates every time you push or pop data from the structure.  Maps were especially painful to shared amongst cores and to get to allocate from a shared memory location. 

    I would recommend spending your time removing the STL factors from the algorithm instead of trying to make the algorithm work. 

    If you are determined to make it work, I recommend these posts for some hints about using an allocator template:

    http://e2e.ti.com/support/development_tools/compiler/f/343/t/200748.aspx?pi195977=1

    http://e2e.ti.com/support/embedded/bios/f/355/t/210699.aspx?pi239031349=2

    Good luck!

    Brandy

     

  • You have to write ...

    typedef std::map<char,STRUCT_AB> AB_MAP;

    Even though you include <map>, the std namespace (where map is defined) is not added to the global namespace by default.  For more discussion, please see this entry from a highly regarded C++ FAQ list.

    Thanks and regards,

    -George