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.

CCS/AM5726: Failing of if condition.

Part Number: AM5726
Other Parts Discussed in Thread: SYSBIOS,

Tool/software: Code Composer Studio

hi,

with the following type of function declaration CCSv7 is not giving any build error, but CCSv6 gives up build error.

#include<stdio.h>
void testFunc(int index1,int index2,float buff[index1][index2],float outBuff[index1][index2]);
int main()
{
    int index1 = 3, index2=3;
    float buff[index1][index2];

    buff[0][0]= 6; //3;
    buff[0][1]= 6; //2;
    buff[0][2]= 9; //4

    buff[1][0]= 2;
    buff[1][1]= 2;
    buff[1][2]= 4;

    buff[2][0]= 1;
    buff[2][1]= 1;
    buff[2][2]= 5;

    float outBuff[index1][index2];
    testFunc(index1,index2,buff,outBuff);
    printf("Complete\n");

}

void testFunc(int index1,int index2,float buff[index1][index2],float outBuff[index1][index2])
{
    int i,j,test,small;

    for(i =0;i<index1;i++)
    {
        test = buff[i][0];
        for(j =0; j<index2;j++)
        {
            if(buff[i][j] < test)    //error seen here
            {
                test = buff[i][j];
            }

        }
        printf("Small in row %d is %d\n",i,test);
    }
}

IN CCSv7: following is the behavior seen

/********************************************************************************************/

In  the above code the expected result had to be 

[C66xx_DSP1] Small in row 0 is 6

Small in row 1 is 2

Small in row 2 is 1

Complete

but the output seen is as follows.

[C66xx_DSP1]  Small in row 0 is 6

Small in row 1 is 4

Small in row 2 is 5

Complete

/********************************************************************************************/

in the above code , inside testFunc the if condition is failing for the 2nd and 3rd row. Can this be explained?

but when ,

void testFunc(int index1,int index2,float buff[index1][index2],float outBuff[index1][index2]) 

is replaced with

void testFunc(int index1,int index2,float buff[INDEX_1][INDEX_2],float outBuff[INDEX_1][INDEX_2])

where INDEX_1,INDEX_2 are macros ( #define INDEX_1 3  , #define INDEX_2 3)

the code works fine and i get the expected output.

Regards

Asha

 

#include<stdio.h>
void testFunc(int index1,int index2,float buff[index1][index2],float outBuff[index1][index2]);int main(){    int index1 = 3, index2=3;    float buff[index1][index2];
    buff[0][0]= 6; //3;    buff[0][1]= 6; //2;    buff[0][2]= 9; //4
    buff[1][0]= 2;    buff[1][1]= 2;    buff[1][2]= 4;
    buff[2][0]= 1;    buff[2][1]= 1;    buff[2][2]= 5;
    float outBuff[index1][index2];    testFunc(index1,index2,buff,outBuff);    printf("Complete\n");
}
void testFunc(int index1,int index2,float buff[index1][index2],float outBuff[index1][index2]){    int i,j,test,small;
    for(i =0;i<index1;i++)    {        test = buff[i][0];        for(j =0; j<index2;j++)        {            if(buff[i][j] < test)            {                test = buff[i][j];            }
        }        printf("Small in row %d is %d\n",i,test);    }}

  • Hi, 

    it is not CCS issue.
    It is compiler issue.

    Please post the console outputs for both build. 

  • Hi,

    Thank you for the reply.

    I have attached the screenshot of the console for both the cases.

    1) Working Case with the macros

    2) If condition Fail case

    Regards

    Asha

  • Console output for a build like below: 

    Please post the text logs, not pictures.

  • Hi,

    1) Console output for if Condition fail case:

    **** Build of configuration Debug for project TestProject ****

    "C:\\ti_psdk_4_3_0_5\\ccsv7\\utils\\bin\\gmake" -k -j 4 all -O

    'Building file: "../TestProject.cfg"'
    'Invoking: XDCtools'
    "C:/ti_psdk_4_3_0_5/xdctools_3_50_04_43_core/xs" --xdcpath="C:/ti/ctoolslib_1_1_1_0/packages;C:/ti/ctoolslib_1_1_1_0/packages/ti;C:/ti_psdk_4_3_0_5/edma3_lld_2_12_05_30C/packages;C:/ti_psdk_4_3_0_5/framework_components_3_40_02_07/packages;C:/ti_psdk_4_3_0_5/framework_components_3_40_02_07/examples;C:/ti_psdk_4_3_0_5/imglib_c66x_3_1_1_0/packages;C:/ti_psdk_4_3_0_5/ipc_3_50_03_04/packages;C:/ti_psdk_4_3_0_5/pdk_k2hk_4_0_9/packages;C:/ti_psdk_4_3_0_5/ltelib_3_01_00_09_light/packages;C:/ti/mcsdk_bios_3_01_04_07/demos;C:/ti_psdk_4_3_0_5/ndk_3_40_01_01/packages;C:/ti_psdk_4_3_0_5/bios_6_73_01_01/packages;C:/ti_psdk_4_3_0_5/uia_2_30_01_02/packages;C:/ti_psdk_4_3_0_5/xdais_7_24_00_04/packages;C:/ti_psdk_4_3_0_5/xdais_7_24_00_04/examples;C:/ti_psdk_4_3_0_5/openmp_dsp_k2x_2_06_02_01/packages;C:/ti_psdk_4_3_0_5/ccsv7/ccs_base;" xdc.tools.configuro -o configPkg -t ti.targets.elf.C66 -p ti.platforms.evmDRA7XX:dsp1 -r release -c "C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2" "../TestProject.cfg"
    making package.mak (because of package.bld) ...
    generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
    configuring TestProject.xe66 from package/cfg/TestProject_pe66.cfg ...
    generating custom ti.sysbios library makefile ...
    Inside EDMA3 Drv Sample getLibs
    will link with ti.sdo.edma3.drv.sample:lib/tda2xx-evm/66/release/edma3_lld_drv_sample.ae66
    Inside EDMA3 Drv getLibs
    will link with ti.sdo.edma3.drv:lib/66/release/edma3_lld_drv.ae66
    Inside EDMA3 RM getLibs
    will link with ti.sdo.edma3.rm:lib/tda2xx-evm/66/release/edma3_lld_rm.ae66
    Starting build of library sources ...
    making F:/SITARA/Totemic_lab_Workspace/hangarian/TestProject/src/sysbios/sysbios.ae66 ...
    gmake[1]: Entering directory `F:/SITARA/Totemic_lab_Workspace/hangarian/TestProject/src/sysbios'
    gmake[1]: Nothing to be done for `all'.
    gmake[1]: Leaving directory `F:/SITARA/Totemic_lab_Workspace/hangarian/TestProject/src/sysbios'
    Build of libraries done.
    cle66 package/cfg/TestProject_pe66.c ...
    'Finished building: "../TestProject.cfg"'

    'Building file: "../Main.c"'
    'Invoking: C6000 Compiler'
    "C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/bin/cl6x" -mv6600 --include_path="F:/SITARA/Totemic_lab_Workspace/hangarian/TestProject" --include_path="C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/include" -g --diag_warning=225 --diag_wrap=off --display_error_number --asm_listing --src_interlist --preproc_with_compile --preproc_dependency="Main.d_raw" --cmd_file="configPkg/compiler.opt" "../Main.c"
    "../Main.c", line 38: warning #179-D: variable "small" was declared but never referenced
    'Finished building: "../Main.c"'

    'Building target: "TestProject.out"'
    'Invoking: C6000 Linker'
    "C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/bin/cl6x" -mv6600 -g --diag_warning=225 --diag_wrap=off --display_error_number --asm_listing --src_interlist -z -m"TestProject.map" -i"C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/lib" -i"C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="TestProject_linkInfo.xml" --rom_model -o "TestProject.out" "./Main.obj" -l"configPkg/linker.cmd" -llibc.a
    <Linking>
    'Finished building target: "TestProject.out"'

    **** Build Finished ****

    2) Console output for Working case:

    **** Build of configuration Debug for project TestProject ****

    "C:\\ti_psdk_4_3_0_5\\ccsv7\\utils\\bin\\gmake" -k -j 4 all -O

    'Building file: "../TestProject.cfg"'
    'Invoking: XDCtools'
    "C:/ti_psdk_4_3_0_5/xdctools_3_50_04_43_core/xs" --xdcpath="C:/ti/ctoolslib_1_1_1_0/packages;C:/ti/ctoolslib_1_1_1_0/packages/ti;C:/ti_psdk_4_3_0_5/edma3_lld_2_12_05_30C/packages;C:/ti_psdk_4_3_0_5/framework_components_3_40_02_07/packages;C:/ti_psdk_4_3_0_5/framework_components_3_40_02_07/examples;C:/ti_psdk_4_3_0_5/imglib_c66x_3_1_1_0/packages;C:/ti_psdk_4_3_0_5/ipc_3_50_03_04/packages;C:/ti_psdk_4_3_0_5/pdk_k2hk_4_0_9/packages;C:/ti_psdk_4_3_0_5/ltelib_3_01_00_09_light/packages;C:/ti/mcsdk_bios_3_01_04_07/demos;C:/ti_psdk_4_3_0_5/ndk_3_40_01_01/packages;C:/ti_psdk_4_3_0_5/bios_6_73_01_01/packages;C:/ti_psdk_4_3_0_5/uia_2_30_01_02/packages;C:/ti_psdk_4_3_0_5/xdais_7_24_00_04/packages;C:/ti_psdk_4_3_0_5/xdais_7_24_00_04/examples;C:/ti_psdk_4_3_0_5/openmp_dsp_k2x_2_06_02_01/packages;C:/ti_psdk_4_3_0_5/ccsv7/ccs_base;" xdc.tools.configuro -o configPkg -t ti.targets.elf.C66 -p ti.platforms.evmDRA7XX:dsp1 -r release -c "C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2" "../TestProject.cfg"
    making package.mak (because of package.bld) ...
    generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
    configuring TestProject.xe66 from package/cfg/TestProject_pe66.cfg ...
    generating custom ti.sysbios library makefile ...
    Inside EDMA3 Drv Sample getLibs
    will link with ti.sdo.edma3.drv.sample:lib/tda2xx-evm/66/release/edma3_lld_drv_sample.ae66
    Inside EDMA3 Drv getLibs
    will link with ti.sdo.edma3.drv:lib/66/release/edma3_lld_drv.ae66
    Inside EDMA3 RM getLibs
    will link with ti.sdo.edma3.rm:lib/tda2xx-evm/66/release/edma3_lld_rm.ae66
    Starting build of library sources ...
    making F:/SITARA/Totemic_lab_Workspace/hangarian/TestProject/src/sysbios/sysbios.ae66 ...
    gmake[1]: Entering directory `F:/SITARA/Totemic_lab_Workspace/hangarian/TestProject/src/sysbios'
    gmake[1]: Nothing to be done for `all'.
    gmake[1]: Leaving directory `F:/SITARA/Totemic_lab_Workspace/hangarian/TestProject/src/sysbios'
    Build of libraries done.
    cle66 package/cfg/TestProject_pe66.c ...
    'Finished building: "../TestProject.cfg"'

    'Building file: "../Main.c"'
    'Invoking: C6000 Compiler'
    "C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/bin/cl6x" -mv6600 --include_path="F:/SITARA/Totemic_lab_Workspace/hangarian/TestProject" --include_path="C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/include" -g --diag_warning=225 --diag_wrap=off --display_error_number --asm_listing --src_interlist --preproc_with_compile --preproc_dependency="Main.d_raw" --cmd_file="configPkg/compiler.opt" "../Main.c"
    "../Main.c", line 38: warning #179-D: variable "small" was declared but never referenced
    'Finished building: "../Main.c"'

    'Building target: "TestProject.out"'
    'Invoking: C6000 Linker'
    "C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/bin/cl6x" -mv6600 -g --diag_warning=225 --diag_wrap=off --display_error_number --asm_listing --src_interlist -z -m"TestProject.map" -i"C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/lib" -i"C:/ti_psdk_4_3_0_5/ti-cgt-c6000_8.2.2/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="TestProject_linkInfo.xml" --rom_model -o "TestProject.out" "./Main.obj" -l"configPkg/linker.cmd" -llibc.a
    <Linking>
    'Finished building target: "TestProject.out"'

    **** Build Finished ****

    regards

    Asha

  • Asha,

    in both cases you use ti-cgt-c6000_8.2.2.
    cgt v8.2.2 uses ANSI C89 with relaxed ansi mode as default. 

    If you use compiler setting like on the following picture: 

    you would get the following errors: 

    Building file: "../main.c"
    Invoking: C6000 Compiler
    "C:/ti/CGT/ti-cgt-c6000_8.2.2/bin/cl6x" -mv6600 --include_path="C:/TI_Trash/CCS901_MSP430P401R/test02_AM5726_RevA_C66xx" --include_path="C:/ti/CGT/ti-cgt-c6000_8.2.2/include" --define=am5726 --define=core1 -g --c89 --strict_ansi --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"

    >> Compilation failure
    subdir_rules.mk:9: recipe for target 'main.obj' failed
    "../main.c", line 3: error #413: a parameter is not allowed
    "../main.c", line 3: error #413: a parameter is not allowed
    "../main.c", line 3: error #413: a parameter is not allowed
    "../main.c", line 3: error #413: a parameter is not allowed
    "../main.c", line 11: error #28: expression must have a constant value
    "../main.c", line 11: error #28: expression must have a constant value
    "../main.c", line 13: warning #2581-D: '//' comments are not allowed in strict C89 mode
    "../main.c", line 30: error #413: a parameter is not allowed
    "../main.c", line 30: error #413: a parameter is not allowed
    "../main.c", line 30: error #413: a parameter is not allowed
    "../main.c", line 30: error #413: a parameter is not allowed
    "../main.c", line 32: warning #179-D: variable "small" was declared but never referenced
    10 errors detected in the compilation of "../main.c".
    gmake: *** [main.obj] Error 1
    gmake: Target 'all' not remade because of errors.

    **** Build Finished ****



    All the above is because C supports variable sized arrays from C99 standard.

  • Hi,

    Thank you for the solution.

    Can i know which ti cgt version supports C99 standards ??

    Regards

    Asha

  • Check options under "C Dialect" present on the picture from my previous post. 
    Check ti-cgt-arm... manuals and release notes. 

  • Hi Tomasz

    Thank you.

    Will check it.

    Regards

    Asha