Search code examples
c++android-ndkblock

NDK Expected unqualified-id before '^' token


I'm new to NDK and new to JAVA, so please bear with me. I have c++ files that I want to build it through NDK build.gradle. And I have the below in my build.gradle file:

 defaultConfig {
        applicationId "com.example.blabla.blabla"
        minSdkVersion 21
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            moduleName "test"
            cFlags "-std=c++11 -fexceptions"
            stl "gnustl_shared"
        }
    }

and I have this line in local.properties:

ndk.dir= pathToMyNDK/AndroidStudio/ndk

In one my C++ files, I have a block definition like this:

typedef void (^ABCD)(string, string);

and a function that takes an argument of that type:

void generateAlphabetLetters(ABCD alph){}

When I try to build the files with NDK, I get the following error that I cannot solve: Expected unqualified-id before '^' token


Solution

  • It is a syntax error as the compiler tells you.

    typedef void (^ABCD)(string, string);
    

    is not valid c++.

    You have lambdas in standard c++.