clang ++ libc ++使用rvalue初始化vector <jsonvalue * =“”>

时间:2018-05-18 21:30:36

标签: android clang libc++

我正在将旧项目更新到最新的android构建系统。 Android Studio 3.1.2和clang / libc ++。该项目使用https://github.com/MJPA/SimpleJSON并且无法像使用gcc那样进行编译     我不知道如何在libc ++中实现向量,但似乎默认构造函数试图用NULL或其他东西实例化JSONValue *而这失败了?     是否有可能我没有在编译中启用正确的定义?包含/内存中的模板特化是在仅在_LIBCPP_CXX03_LANG不定义时定义的块内。我检查过,这是源中唯一检查定义的地方。我正在使用-std = c ++ 11编译包括CXX03功能?:

class JSONValue;
typedef std::vector<JSONValue *> JSONArray;
class JSONValue
{
    friend class JSON;

    public:
        JSONValue(/*NULL*/);
        JSONValue(const TCHAR *m_char_value);
        JSONValue(const tstring &m_string_value);
        JSONValue(bool m_bool_value);
        JSONValue(double m_number_value);
        JSONValue(const JSONArray &m_array_value);
        JSONValue(const JSONObject &m_object_value);
        ~JSONValue();

        JSONValue *Clone() const;

        bool IsNull() const;
        bool IsString() const;
        bool IsBool() const;
        bool IsNumber() const;
        bool IsArray() const;
        bool IsObject() const;

        // change the internal type of the JSONValue so that we can keep the contained objects around for
        // another instance to clean up. be VERY careful about using this unless you know how to clean up
        // memory in a map of pointers on your own. This is major hack territory but it was the fastest
        // way to fix a double free without completely changing the printer discovery call chain.
        void Detach(void) { type = JSONType_Null; };

        const tstring &AsString() const;
        bool AsBool() const;
        double AsNumber() const;
        const JSONArray &AsArray() const;
        const JSONObject &AsObject() const;

        tstring Stringify() const;

        JSONValue* CopyObjectField(const TCHAR *fieldname);

    protected:
        static JSONValue *Parse(const TCHAR **data);

    private:
        static tstring StringifyString(const tstring &str);
        JSONValue *CloneSimpleValue(const JSONValue *);
        JSONValue *RecursiveCloneObject(const JSONObject &inobj) const;
        JSONValue *RecursiveCloneArray(const JSONArray &inarray) const;
        JSONType type;
        tstring string_value;
        bool bool_value;
        double number_value;
        JSONArray array_value;
        JSONObject object_value;
};

JSONValue array;

JSONValue对象的实例化会在编译期间导致以下失败:

 FAILED: C:\Users\kmurphy\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=x86_64-none-linux-android --gcc-toolchain=C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sysroot   -ID:/SPTX/Include -isystem C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include -isystem C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/android/support/include -isystem C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include -isystem C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sysroot/usr/include/x86_64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++11 -frtti -fexceptions -x c++ -O0 -fno-limit-debug-info  -fPIC -MD -MT D:/SPTX/Builds/Android/tlibJSON/x86_64/CMakeFiles/tlibJSON.dir/JSONValue.cpp.o -MF D:\SPTX\Builds\Android\tlibJSON\x86_64\CMakeFiles\tlibJSON.dir\JSONValue.cpp.o.d -o D:/SPTX/Builds/Android/tlibJSON/x86_64/CMakeFiles/tlibJSON.dir/JSONValue.cpp.o -c D:\SPTX\Projects\Parsers\tlibJSON\JSONValue.cpp
  In file included from D:\SPTX\Projects\Parsers\tlibJSON\JSONValue.cpp:25:
  In file included from D:\SPTX\Projects\Parsers\tlibJSON/stdafx.h:6:
  In file included from D:/SPTX/Include/tlibTYPES_android.h:16:
  In file included from C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\string:470:
  In file included from C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\string_view:169:
  In file included from C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\__string:56:
  In file included from C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\algorithm:643:
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\memory:2050:9: error: cannot initialize a member subobject of type 'JSONValue **' with an rvalue of type 'long'
        : __value_(_VSTD::forward<_Up>(__u)){};
          ^        ~~~~~~~~~~~~~~~~~~~~~~~~
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\memory:2135:9: note: in instantiation of function template specialization 'std::__ndk1::__compressed_pair_elem<JSONValue **, 0, false>::__compressed_pair_elem<long, void>' requested here
        : _Base1(std::forward<_Tp>(__t)), _Base2() {}
          ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\vector:423:7: note: in instantiation of function template specialization 'std::__ndk1::__compressed_pair<JSONValue **, std::__ndk1::allocator<JSONValue *> >::__compressed_pair<long, true>' requested here
        __end_cap_(nullptr)
        ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\vector:473:5: note: in instantiation of member function 'std::__ndk1::__vector_base<JSONValue *, std::__ndk1::allocator<JSONValue *> >::__vector_base' requested here
      vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
      ^
  D:\SPTX\Projects\Parsers\tlibJSON\JSONValue.cpp:228:13: note: in instantiation of member function 'std::__ndk1::vector<JSONValue *, std::__ndk1::allocator<JSONValue *> >::vector' requested here
                  JSONArray array;
                            ^
  In file included from D:\SPTX\Projects\Parsers\tlibJSON\JSONValue.cpp:25:
  In file included from D:\SPTX\Projects\Parsers\tlibJSON/stdafx.h:6:
  In file included from D:/SPTX/Include/tlibTYPES_android.h:16:
  In file included from C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\string:470:
  In file included from C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\string_view:169:
  In file included from C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\__string:56:
  In file included from C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\algorithm:643:
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\memory:2145:9: error: no matching constructor for initialization of '__compressed_pair_elem<JSONValue **, 0>'
        : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
          ^      ~~~~~~~~~~~~~~~~~~~~~~~
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\__split_buffer:309:7: note: in instantiation of function template specialization 'std::__ndk1::__compressed_pair<JSONValue **, std::__ndk1::allocator<JSONValue *> &>::__compressed_pair<long, std::__ndk1::allocator<JSONValue *> &>' requested here
      : __end_cap_(nullptr, __a)
        ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\vector:1567:49: note: in instantiation of member function 'std::__ndk1::__split_buffer<JSONValue *, std::__ndk1::allocator<JSONValue *> &>::__split_buffer' requested here
      __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
                                                  ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\vector:1588:9: note: in instantiation of function template specialization 'std::__ndk1::vector<JSONValue *, std::__ndk1::allocator<JSONValue *> >::__push_back_slow_path<JSONValue *const &>' requested here
          __push_back_slow_path(__x);
          ^
  D:\SPTX\Projects\Parsers\tlibJSON\JSONValue.cpp:256:10: note: in instantiation of member function 'std::__ndk1::vector<JSONValue *, std::__ndk1::allocator<JSONValue *> >::push_back' requested here
                          array.push_back(value);
                                ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\memory:2037:8: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'long' to 'const std::__ndk1::__compressed_pair_elem<JSONValue **, 0, false>' for 1st argument
  struct __compressed_pair_elem {
         ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\memory:2037:8: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'long' to 'std::__ndk1::__compressed_pair_elem<JSONValue **, 0, false>' for 1st argument
  struct __compressed_pair_elem {
         ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\memory:2049:3: note: candidate template ignored: substitution failure [with _Up = long, $1 = void]
    __compressed_pair_elem(_Up&& __u)
    ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\memory:2054:3: note: candidate constructor template not viable: requires 3 arguments, but 1 was provided
    __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,
    ^
  C:/Users/kmurphy/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include\memory:2043:13: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
    constexpr __compressed_pair_elem() : __value_() {}
              ^
  2 errors generated.
  ninja: build stopped: subcommand failed.

1 个答案:

答案 0 :(得分:1)

有人是<form action="sent.php" method="post" enctype="multipart/form-data"> <input type="file" id="file" name="file" class="inputfile" onchange="danee()"> <label for="file" class="chose" id="chose">Wybierz plik</label> <div id="info"> <input type="email" name="email" id="email" onchange="checkEmail()" autocomplete="email" class="userdata" placeholder="E-mail"><Br/> <input type="password" name="pass" id="pass" onchange="checkPass()" autocomplete="new-password" class="userdata" placeholder="Hasło do pliku"><Br/> <input type="submit" value="Wyślij" id="send"> </div> </form> ,这是打破这个的原因。这不是STL的错。你应该找到拥有#define nullptr 0的人并告诉他们停止。