Search code examples
visual-studioandroid-ndkunreal-engine4

Unreal Engine 4 - Android NDK - Visual Studio - sys/cdefs.h - "No function renaming possible"


I'm trying to compile Unreal Engine 4 project including Android NDK in Visual Studio 2013, but there's an error occurring I don't know how to address

PublicIncludePaths.Add("D:/NVPACK/android-ndk-r9c/platforms/android-19/arch-arm/usr/include");

D:\NVPACK\android-ndk-r9c\platforms\android-19\arch-arm\usr\include\sys/cdefs.h(252): fatal error C1189: #error : "No function renaming possible"

Here's code responsible for the error

#ifdef __lint__
#define __RENAME(x) __symbolrename(x)
#else
#error "No function renaming possible"
#endif /* __lint__ */

Solution

  • Stupid me! I was trying to compile the source code for Unreal Editor, in other words for Windows. Using Editor Launch/Package for Android is the right way to compile with Android NDK headers.

    .Build.cs

    if ((Target.Platform == UnrealTargetPlatform.Android))
    {
        PublicIncludePaths.Add("D:/NVPACK/android-ndk-r9c/platforms/android-19/arch-arm/usr/include");
    }
    

    .cpp

    #include "Android/AndroidApplication.h"
    ...
    JNIEnv* Env = FAndroidApplication::GetJavaEnv();
    jint VersionJint = Env->GetVersion();
    int8 Version = (int8)VersionJint;
    GEngine->AddOnScreenDebugMessage(2, 0.5f, FColor::Cyan, FString::FromInt(Version));
    

    Looks like I need exceptions for all #includes too.