Error: no member named 'to_string' in namespace 'std'; did you mean 'toString'? Gradle+Cmake
Asked Answered
C

1

1

<string> is included. What is wrong in std::to_sting(intVar)?

cppreference. Does it mean CLang does not meet STandarD?

Another question helped, but the answers are not good (for me) because:

  1. write own std::to_string() is bad idea. Standard is standard. If i write own implementation. I need to wrap it with defines to prevent errors from another compilers/toolchains which does not leak std features. And this impl still leaks full-featured STD.
  2. Application.mk - is bad idea too since lastest studio offers Gradle+CMake. Makefile is too ugly and hard for manual using.
  3. My solution is better.
Croy answered 12/1, 2017 at 0:11 Comment(1)
Possible duplicate of Android ndk std::to_string supportFacility
C
2

Does it mean CLang does not meet STandarD?

No, it is because minimal std library set in Android NDK by default.

I use gradle build system:

android {
  ...
  defaultConfig {
    ...
    // This block is different from the one you use to link Gradle
    // to your CMake build script.
    externalNativeBuild {
      cmake {
        ...
        // Use the following syntax when passing arguments to variables:
        // arguments "-DVAR_NAME=VALUE"
        // ------------------- ANSWER -------------------
        arguments "-DANDROID_STL=c++_shared"
      }
    }
  }
  buildTypes {...}

  // Use this block to link Gradle to your CMake build script.
  externalNativeBuild {
    cmake {...}
  }
}

Read these:
https://developer.android.com/ndk/guides/cmake.html#variables
https://developer.android.com/ndk/guides/cpp-support.htm

Croy answered 12/1, 2017 at 1:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.