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.

Compiler: running a static code analyzer (CodeSonar) on a simple TI ARM 16.9.4.LTS compiler program gives errors on missing "STLport" header files e.g. “s_c__linux.h” - where are these files?

Tool/software: TI C/C++ Compiler

Running a static code analyzer (like CodeSonar) on Ubuntu 16.04 on a simple TI ARM 16.9.4.LTS compiler program like this:

#include <cstring>

int main()

{

    return 0;

}

...gives parse and build errors because of what appears to be missing header files from the embedded and modified "STLport" library that comes with the TI compiler. In fact, for the program shown, there are three types of errors created by the static analyzer:

(i)      Missing include file errors (x4) like “s_c__linux.h”, "s_c_stl_mycomp.h", "s_c__native_headers.h", "u_cstring" appear to be genuinely reported by CodeSonar as missing. This is potentially true since they do not exist anywhere on the file system. Can TI provide these header files or what am I missing for a solution here?

(ii)    Unable to determine platform type where CodeSonar appears to genuinely report that preprocessor error (x1) by CodeSonar of ‘#error "can't determine endianess"’ is because neither of the endian symbols _STLP_BIG_ENDIAN or _STLP_LITTLE_ENDIAN are defined in file "s_c_features.h" but initial research suggests these are setup by the TI compiler header “./ti-cgt-arm_16.9.4.LTS/lib/src/s_c__ti.h” when __little_endian__” which should be defined in a system file like /usr/include/endian.h but appears not to be the case and perhaps suggests possible platform mismatch or oversight (Ubunti 16.04 and the TI compilers appear to use “__LITTLE_ENDIAN” instead). This needs more investigation.

(iii)   Undefined macro where CodeSonar appears to genuinely report the error (x1) of ‘#    include _STLP_NATIVE_CPP_C_HEADER(cstring)‘. CodeSonar can legitimately require that the parameter to an include statement be a filename but the reason the symbol _STLP_NATIVE_CPP_C_HEADER is not resolved by the preprocessor would likely be caused by the same issue as item (i) above i.e. missing STLport header files.

  • (i) Those header files are in $(CG_TOOLS_ROOT)/include just like stdio.h
    (ii) The TI compiler pre-defines the macro __little_endian__ when the target is little-endian. Presumably CodeSonar has a configuration file to mimic the compiler's pre-defines; this variable needs to be set appropriately in that file
  • Thank-you so much for your help.

    The answer to your question (ii) is "yes" but on (i) I cannot find the files you mention, however, I have only installed the TI ARM 16.9.4.LTS distribution called "ti_cgt_tms470_16.9.4.LTS_linux_installer_x86.bin". So are you saying that these four header files should be in this distribution...or that I need an additional tools download? Just to demonstrate my problem, here are a couple of "ls" commands on the clean compiler install directory's showing that none of these four files e.g. "s_c_stl_mycomp.h" exist in my fresh new compiler install:

    ls ./ti-cgt-arm_16.9.4.LTS/include/s_c_*.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c_compat.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c__epilog.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c_features.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c_host.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c_locale.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c__prolog.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c_stl_confix.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c__system.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c__ti.h
    ./ti-cgt-arm_16.9.4.LTS/include/s_c_user_config.h

    ls ./ti-cgt-arm_16.9.4.LTS/include/u_cstring.h
    ls: cannot access './ti-cgt-arm_16.9.4.LTS/include/u_cstring.h': No such file or directory
  • Ray Felton said:
    (i)      Missing include file errors (x4) like “s_c__linux.h”

    Taking the example of the missing s_c__linux.h include file, if you look in the include/s_c__system.h file the include of s_c__linux.h is inside a #if block:

     (__linux__)
    #  include <s_c__linux.h>
    /*
    #  ifdef __KCC
    #    include <s_c__kai.h>
    #  endif
    */
    #elif defined (_WIN32) || defined (__WIN32) || defined (WIN32) || defined (__WIN32__) || \
          defined (__WIN16) || defined (WIN16) || defined (_WIN16)
    
    #  include <s_c__windows.h>
    #else
    #  include <s_c__ti.h>
    #endif
    
    #if !defined (_STLP_COMPILER)
    /* Unable to identify the compiler, issue error diagnostic.
     * Edit <config/stl_mycomp.h> to set STLport up for your compiler. */
    #  include <s_c_stl_mycomp.h>
    #endif

    I think the problem is that your CodeSonar setup thinks that linux or __linux__ are defined which then causes an include of the s_c__linux.h file to be attempted, which is not part of the TI compiler installation.

    Therefore, the definition of the pre-defined symbols used by CodeSonar needs to match the actual pre-defined symbols used by the TI compiler.