This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Calling C++ function on C main

Hi,

I'm a beginner on MCU programming (STM32F4 discovery)

I'm building my code on C language. Recently, i find some library in C++ can achieved my job.
However, when i compile it, errors occurred.

"#20: identifier "namespace" is undefined _RWSTD_NAMESPACE_BEGIN (__rw)
"#65: expected a ";" ......

I think the issue comes from the compiler is C compiler which cannot compile C++ code.

How can i do with this case ?

Thank you.

Parents
  • Not quite.

    The compiler can compile 'C' and C++

    www.keil.com/.../armcc_chr1359124192674.htm

    Usually, the compiler decides automatically from the filename extension:
    .c files will be compiled as 'C';
    .cpp files will be compiled as C++.

    Or you can force it explicitly by specifying options.

    In general, if you want to use any C++ code, it's usually easiest to make your whole project C++.

    In most cases, 'C' source code will "just work" when compiled as C++.

    "I'm a beginner on MCU programming"

    The above is entirely general - nothing specific to microcontrollers or Keil or ARM.

Reply
  • Not quite.

    The compiler can compile 'C' and C++

    www.keil.com/.../armcc_chr1359124192674.htm

    Usually, the compiler decides automatically from the filename extension:
    .c files will be compiled as 'C';
    .cpp files will be compiled as C++.

    Or you can force it explicitly by specifying options.

    In general, if you want to use any C++ code, it's usually easiest to make your whole project C++.

    In most cases, 'C' source code will "just work" when compiled as C++.

    "I'm a beginner on MCU programming"

    The above is entirely general - nothing specific to microcontrollers or Keil or ARM.

Children
No data