ANSI C

07 Sep 2011

Is there any way that I can compile an ANSI C program with the online compiler ? Maybe by setting some flag or something ? I really like the development environment but I have too much ANSI C code lying around to patch all the typecast that I get when compiling with the C++ Compiler.

The documentation states that it is a C/C++ compiler, if it is not I think that it is very confusing to advertise it like this ...

Christophe

07 Sep 2011

I code in C and I haven't run into a problem .. yet

-edit ah you want to bring old code .. misread.

have you tried importing and pointing to the files on your pc?

08 Sep 2011

Thank you for your response, at least somebody who responds :)

I have no clue what you mean with "pointing to the files on your pc". What I did was importing all the C files and when I press compile I get all sorts of compile errors. These compile errors do not surprise me as they are the typical errors that you get when you try to compile a C program with a C++ compiler. One example is that the C++ compiler is more strict on certain casts to void pointers.

So my question is: How do I put the compiler in C mode.

Christophe

10 May 2014

Hello Christopher, I start to use mbed and I discover the same problem. My file was in ANSI C and when I import into mbed to change the platform I can't compile them. errors show that ANSI C files should be migrate to C++ stucture... this is a big amount of work.

Have you solve with some hints? May you help me?

Thank you.

Maurizio

10 May 2014

Hi Maurizio Brignoli,

C files are compiled as C files, it should work. Which ANSCI C version did you use for writing the program? Can you share the error output?

Flag c99 is set for the online compiler.

Update: update mbed library, older revision (not certain up to which one) were using flag to compile c sources by c++ compiler.

Regards,
0xc0170

31 May 2014

I belive I have to use some istruction to compile ANSI C library with C++ compiler... like this sentece: extern "C"

I need to study how to do this. Any hints?

Thank you Regards

31 May 2014

Most recurrent errors are: Error: Identifier "namespace" is undefined in "extras/mbed_3d0ef94e36ec/DigitalIn.h", Line: 23, Col: 2 Error: Expected a declaration in "extras/mbed_3d0ef94e36ec/DigitalIn.h", Line: 88, Col: 2

31 May 2014

Namspace is a c++ concept so it can't be used in an ansi c program. As most stuff in mbed.h is c++, don't #include <mbed.h>.