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.

AM62A7: MCU-R5F compile with C and C++ file, with STL

Part Number: AM62A7

Hi, Ti

HW: custom hardware

SDK version: 09_01_00_07

Tools: ti-cgt-armllvm_3.2.0.LTS

We try to compile MCU-R5F with C and C++ files, and C++ files use STL library,  e.g.:  #include <vector>

We modify the makefile, but resport error. When we add C++ include path: 

-I${CG_TOOL_ROOT}/include/c++/v1 \
-I${CG_TOOL_ROOT}/include/armv6m-ti-none-eabi/c++/v1 \
Should we add some other include_path or lib_path?
Thanks
  • Please do not ...

    we add C++ include path: 

    -I${CG_TOOL_ROOT}/include/c++/v1 \
    -I${CG_TOOL_ROOT}/include/armv6m-ti-none-eabi/c++/v1 \

    The compiler automatically sets those paths for you.  

    Please be sure the source files you use from ...

    SDK version: 09_01_00_07

    ... are documented and tested to work when built as C++ code.  They may only support being built as C code.

    If these files from the SDK do support being built as C++ code, then this documentation shows you how to tell the compiler to build a file as C++ or C.

    Thanks and regards,

    -George

  • Hi, George

    Thanks for your reply,

    1. There are both C files and C++ files in program, all participate in compilation, in this case, could the compiler support?

    2. If a C file inculde  .h file which include C++ STL .h file, like:

          // a.h

               #include <vector>

          // b.c

               #include "a.h"

    When compile it, this .c file should be build as C code or C++?  In makefile:

    $(CC) -c $(CPPFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $<  OR
    $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $<  
    I think this b.c file should be build as C++ code, as you said, use '-x c++', Am I right?
  • Please note that due to the local holiday, you may not get a response from t he compiler experts until Tuesday of next week.

  • I need to repeat ...

    Please be sure the source files you use from ...

    SDK version: 09_01_00_07

    ... are documented and tested to work when built as C++ code.

    I am not familiar with this SDK.  I do not know if it supports being built as C++ code.  If it doesn't, then you must always compile it as C code.

    1. There are both C files and C++ files in program, all participate in compilation, in this case, could the compiler support?

    It is possible.  But there are details which must be addressed.  Please see this FAQ (not from TI).

    If a C file inculde  .h file which include C++ STL .h file, like:

          // a.h

               #include <vector>

          // b.c

               #include "a.h"

    When compile it, this .c file should be build as C code or C++?

    By default, it is built as C code.  If you use the build option -x c++, you override the default and tell the compiler to compile the source file as C++, even if the file extension is .c.

    In makefile

    I cannot comment on the code from your makefile.  It depends on what all the variables expand to.

    Thanks and regards,

    -George