Android NDK - How to resolve K&R style function declarations

时间:2018-05-09 02:46:03

标签: android cmake android-ndk

I need to compile some c source code, and there are a lot of K&R style function declarations in it like this:

static int
foo(bar) // no type info
char bar; // the type is declared here
{
    return bar * 2;
}

I'm using Android Studio and CMakeLists to build these files, it complains that "Can't resolve type 'bar'", so I guess it cannot recognize K&R style function declarations.

Is there any way to resolve this kind of problem?

2018/05/10 Updated

At last, I found out that although Android Studio shows "Can't resolve type 'bar'" in red error messages, I can still run the project on an Android device with correct behavior. (The calculation result of K&R style functions are all correct)

My environment:

  • macOS 10.13.4
  • Android Studio 3.1.1
  • NDK 16.1.4479499
  • CMake 3.6.4111459

0 个答案:

没有答案