MBED Library Revision 41

25 Jul 2012

You lost me again. Code which compiled fine a few weeks ago now won't compile with Mbed lib. Rev 42. Went back to an old Rev 26 an it compiles OK.

The errors start with

"identifier "namespace" is undefined" in file "mbed.bldFileHandle.h", Line: 18, Col: 1

"expected a ";"" in file "mbed.bldFileHandle.h", Line: 18, Col: 15

Any advice, reading you can point me to.

25 Jul 2012

Hi Tim,

Tim Exton-McGuinness wrote:

won't compile with Mbed lib. Rev 42. Went back to an old Rev 26 an it compiles OK.

The new mbed library trigger a new build system that compiles C files as C and C++ files as C++.

You can read more information about this change on this forum post: http://mbed.org/forum/news-announcements/topic/3686/

In short, you just need to rename the ".c" file that is failing to build to ".cpp".

HTH, Emilio

16 Mar 2013

What do you do if all your files are .cpp or .h and still get this error?

16 Mar 2013

If you can't figure out which part of the code is responsible you can comment out code until the error is gone. Or if you want help the best option is publishing your code, and making a new topic with the link to the published code, then we can import your entire code and see if we can find the error.

16 Mar 2013

Thanks. That helped. Deep down in a directory of a library I imported I missed a .c file.

26 Feb 2015

I just updated a program from mbed lib v26 to the latest (v94).

I get a ton of these errors.

They appear to come from .h files inside the mbed library.

To solve, rename absolutely EVERY .c file to .cpp. Even if you think it doesn't matter because you're not using any C++ features, and the code should be valid C - because you're including the mbed libs, it's no longer just C, so it won't work. Rename it.

26 Feb 2015

@andersop Why would you rename every c file to cpp?

26 Feb 2015

Because of what Emilio mentioned in 2012 ;). A long time ago, every user file was compiled as C++, even if it was called .c. So often people named files which just contained functions as .c files. Even though they used for example the mbed library, which is C++. Now if you update to a newer library it is compiled as C file, and will not accept the mbed library. Easiest solution is renaming all your files from .c to .cpp.