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.

C6000 8.1.2 compiler error



I got a few compiler errors with 8.1.2 CGT, while 7.4.4 CGT works fine. The error messages comes in pairs as following and happen at random places. I captured a place with empty line (picture attached). Thanks for your help.

first substitution argument is not the first variable argument

format argument index is greater  than number of parameters

  • I suspect all of these errors have a common cause.  I need to reproduce it to explain what happened.  Please preprocess one of the source files that have one of these diagnostics, and attach it to your next post.  Also show all the build options exactly as the compiler sees them.

    Thanks and regards,

    -George

  • Hi George,


    The errors are actually all in stdio.h line 198. I will send you a pre-processed file through email.


    Yimin

  • I can tell you what occurred.  But I don't know how it happened.

    The file stdio.h you have is corrupt.  The lines for the declaration of the functions sprintf and snprintf are messed up somehow.  Since I am looking at the post-processed form of the wrong code, I'm not sure how it looks in your copy of stdio.h.  But these are the correct lines ...

    extern _CODE_ACCESS int sprintf(char *_string, const char *_format, ...)
                   __ATTRIBUTE ((__format__ (__printf__, 2, 3)));
    extern _CODE_ACCESS int snprintf(char *_string, size_t _n, 
    				 const char *_format, ...)
                   __ATTRIBUTE ((__format__ (__printf__, 3, 4)));

    So change your copy so the lines for sprintf and snprintf match these.  Or, better yet, re-install version 8.1.2.  

    I cannot reproduce this problem.  When I install version 8.1.2, I get the correct stdio.h.  So I cannot tell you how this occurred.

    Thanks and regards,

    -George

  • stdio.hHi George,

    I don't see the corruption in the area you highlighted. Here is stdio.h. I will reinstall and try to build again.
     Thanks.

    regards,

    Yimin

  • Hi,

    I reinstalled 8.1.2, still got the same error. I also installed 8.1.0, also got the same error. Did you notice anything wrong in the stdio.h I attached in my last post?

    regards,

    Yimin

  • Yimin Zhang said:
    Did you notice anything wrong in the stdio.h I attached in my last post?

    No.

    The problem must occur during preprocessing.  I am unable to reproduce it.  Please submit your entire CCS project.  Please see this post for details on how to do that.  I'm worried that, even with the CCS project, I will not be able to reproduce the problem.  But that is the only way I see to move forward.

    Thanks and regards,

    -George

  • Look for any definitions of a macro named sprintf or snprintf in your source code. Remove them.
  • they are both used extensively in the code. Is this a known issue in CGT 8.x?

  • You can use sprintf and snprintf all you like, but you are not supposed to redefine them
  • dts-flib-osfb-tables-128band-f32.zipI removed a redefinition of snprintf and all these errors are gone. Now I have a new set of errors. There are again 8.1.2 errors, while 7.4.4 works fine. I attached one pp file. Can you see what is wrong? Thanks.

  • Thanks for sending in a test case.

    The .pp file has this source line ...

    const DTS_ALIGN_TO( 128 ) float dts_flib_osfb_f32_coeff_analysis_128[2048] =

    It appears DTS_ALIGN_TO is a preprocessor macro that becomes a gcc attribute or _Pragma.  However, that is not the case.  There is no definition of DTS_ALIGN_TO in the .pp file.  I suspect some other preprocessor problems are going on.  As a debugging technique, consider building with the option --gen_acp_raw and inspecting the resulting .rl file.  Read more about this option in the C6000 compiler manual.

    Yimin Zhang said:
    while 7.4.4 works fine

    I cannot reproduce that behavior.

    Thanks and regards,

    -George

  • Hi George,

    Thanks. I can see DTS_ALIGN_TO is the problem, but somehow 7.4.4 tools is able to resolve the macro to the following line.

    const __attribute__( ( aligned( 128 ) ) ) float dts_flib_osfb_f32_coeff_analysis_128[2048] =

    The definition is in a header file.

    /* Sets the struct to the specified alignment */
    #if DTS_MSVC
    #define DTS_ALIGN_TO( a )               __declspec( align( a ) )
    #elif DTS_RVCT || DTS_GCC || DTS_XCC /* #if DTS_MSVC */
    #define DTS_ALIGN_TO( a )               __attribute__( ( aligned( a ) ) )
    #endif /* #if DTS_MSVC */

    In another header file,

    #define DTS_RVCT    defined(__ARMCC_VERSION)          /* The compiler is RVCT, including ADS */
    #define DTS_XCC     defined(__XCC__)                  /* Tensilica xt-xcc or xt-xc++ */
    #define DTS_GCC     (defined(__GNUC__) && !DTS_RVCT && !DTS_XCC)  /* The compiler is general GCC, excluding RVCT GNU mode and xt-xcc */

    I cannot find any of those definition in either compilers. Is it possible one of the definition is hidden somewhere in 7.4.4?

    Can list file help me figure this one out? How to turn raw list file on in CCS? thanks.


    Yimin

  • I recommend you make two changes to the source.  Change the DTS_GCC macro to this ...

    #define DTS_GCC ((defined(__GNUC__) && !DTS_RVCT && !DTS_XCC) || (defined(__TI_COMPILER_VERSION__) && (__TI_COMPILER_VERSION__ >= 7004000)))
    

    This checks that the TI compiler predefined symbol __TI_COMPILER_VERSION__ is available, and it indicates you are building with at least version 7.4.0.  This compiler version, and all higher versions, accept GCC attributes by default.  This change causes DTS_ALIGN_TO to map to the GCC attribute for alignment.  

    To guard against future problems of this sort, you should also change the definition of DTS_ALIGN_TO to the following ...

    #if DTS_MSVC
    #define DTS_ALIGN_TO( a )               __declspec( align( a ) )
    #elif DTS_RVCT || DTS_GCC || DTS_XCC /* #if DTS_MSVC */
    #define DTS_ALIGN_TO( a )               __attribute__( ( aligned( a ) ) )
    #else
    #warn no definition for DTS_ALIGN_TO
    #endif /* #if DTS_MSVC */
    

    Lines 5-7 mean you will get a warning if is ever the case that the DTS_ALIGN_TO macro is not defined.

    Thanks and regards,

    -George

  • Thanks. Your suggestion works. I have a new error. The following line,

            p_out[index] = __builtin_bswap32( p_in[index] );

    With 7.4.4, there is a warning for the implicitly declared function. With 8.1.2, there is an error: builtin function not supported.

    any suggestions? Thanks.

    Yimin

  • Neither version of the compiler supports __builtin_bswap32.  They go about reporting that fact differently.

    Yimin Zhang said:
    any suggestions?

    I tried using the intrinsics _swap4 and _swap2 as follows ...

    swapped = _swap4(_swap2(val)); 

    Unfortunately, the compiler does not recognize _swap2, even though it is documented in the compiler manual.  So, I filed CODEGEN-1967 in the SDOWP system to have this addressed.  You are welcome to follow it with the SDOWP link below in my signature.

    I did determine that this code works ...

    swapped = _swap4(_packlh2(val, val));

    Not as read-able.  But I suppose you can wrap it in a macro with a better name.

    Thanks and regards,

    -George

  • This is a documentation error. _swap2 is a macro, not an intrinsic. It is defined in c6x.h, which is in the compiler include directory: 
     #define _swap2(src) _packlh2((src), (src)) 

    Include the c6x.h header to use the macro, or you can use the intrinsic it is defined to.

  • It was my mistake to not include <c6x.h>.  So, to summarize, an alternative to __builtin_bswap32 is something similar to ...

    #include <c6x.h>
    #define byte_swap(val) (_swap4(_swap2(val)))

    Thanks and regards,

    -George