Compiling C source files with -std=c99 C99

Hello,

My project has a mix of cpp and c files, and I am trying to compile both of them under Android.
The problem is, my C code isn’t ANSI, and needs to be compiled with c99 standard.

In order to compile under that standard, I tried adding the following flag:

LOCAL_CFLAGS := -std=c99

In Android.mk, but unfortunately, it keeps showing a warning while compiling:

cc1plus: warning: command line option '-std=c99' is valid for C/ObjC but not for C++ [enabled by default]

How can I properly add the flag to the c sources only?

Thanks!

… I am totally lost with this. I wonder if there are specific flags that I should try other than -std=c99 ?

Have you considered compiling you C code separately and only linking it to C++? I don’t know much about it, but it seems as a reasonable approach.

I have considered that approach earlier, but the process of compiling the source into a library seemed awfully tedious, especially since I have to compile for multiple architectures. (Not to mention the fact that I am still tweaking the C source code).

I need to resolve this issue within a week, max. If I couldn’t figure out the current problem, at least I can be assured there is a Plan B :slight_smile:
(i.e. I’ll just use the linking approach)

Thanks.