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

亡梦爱人 提交于 2019-12-08 05:16:14

问题


<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.

回答1:


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



来源:https://stackoverflow.com/questions/41603049/error-no-member-named-to-string-in-namespace-std-did-you-mean-tostring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!