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.

is CCS standard?

Hello,

I am trying to compile some code, which I believe is standard c or c++, but i get quite a few errors.

example:


void test ( int& d)
{
 d= d+2;   
}

main
{
int doo= 0;
        test (doo);
}

it gives me these errors:

expected a ")"
identifier "d" is unidentified  , which it clearly is and
unnamed prototyped parameters not allowed when body is present   

another example:

bool t = false;
identifier "bool" is undefined

another example would be

for ( int i = 0; ..... etc etc)

wont work unless i is defined outside the for loop with volatile keyword i.e. volatile int i = 0 ,

 

is this how c/c++ work, or I am wrong or my compiler is worng?

Thank you

  • Hi,

     

    By just reading your posting I would like to suggest to you to read

    a good book on how to write C programs.

    I am not a good C programmer but did spot the mistakes at first sight.

     

    Even though useless as a program, I corrected your code a bit, it does compile :

    void test(int d)
    {
        d = d + 2;
    }

    void main(void)
    {
        int doo = 0;
        int i;

        test(doo);
        for(i = 0; i < 100; i++)
        {
            doo++;
        }
    }

     

    roelofh@baywatch:~$ cl2000 --verbose tau.c

    TMS320C2000 C/C++ Compiler              v5.2.5
    Tools Copyright (c) 1996-2010 Texas Instruments Incorporated
       "tau.c"   ==> test
       "tau.c"   ==> main

    roelof

     

  • Tau said:

    void test ( int& d)

    References -- the "int&" syntax in the declaration of a variable or parameter -- are part of C++, but not C.  Your file should have the extension .cpp, or you should use the -fg option.

    Tau said:

    main
    {

    The correct syntax for declaring main() is "int main(int argc, char *argv[])" or "void main(void)".

    Tau said:

    bool t = false;
    identifier "bool" is undefined

    TI compilers support C89, which does not include the "bool" type.  However, C++ does include "bool";  again, name your file with a .cpp extension or use -fg.

    Tau said:

    for ( int i = 0; ..... etc etc)

    Declaring a variable within a for-statement is a C++ feature, and is not part of C.  Again, .cpp or -fg.

  • Thanks, renaming the file to main.cpp fixed the problem.

    hmmm, at school they teach us that c and c++ are the same. wasted money.