Не удается распознать _Nonnull при сборке adb с помощью g++

Я пытаюсь собрать adb из исходного кода AOSP android 7.1.2 и скомпилировать его с помощью g++ (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609, медленно добавляя включения и библиотеки на основе Android.mk и исправляя жалобы на компилятор, как я иду. Пока я добрался до команды ниже, но я не уверен, как решить ошибку ниже:

adb-1.0.36/system/core$ g++ -o ./adb/adb_client{,.cpp} -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wvla -DADB_REVISION='1.0.36' -std=c++14 -I./base/include/ -I./include -lrt -ldl -lpthread -fvisibility=hidden
In file included from ./adb/adb_client.cpp:20:0:
./adb/adb_client.h:28:67: error: expected ‘,’ or ‘...’ before ‘error’
 int adb_connect(const std::string& service, std::string* _Nonnull error);
                                                               ^
./adb/adb_client.h:29:68: error: expected ‘,’ or ‘...’ before ‘error’
 int _adb_connect(const std::string& service, std::string* _Nonnull error);
                                                                ^
./adb/adb_client.h:37:66: error: expected ‘,’ or ‘...’ before ‘result’
 bool adb_query(const std::string& service, std::string* _Nonnull result,
                                                              ^
./adb/adb_client.h:41:66: error: expected ‘,’ or ‘...’ before ‘serial’
 void adb_set_transport(TransportType type, const char* _Nullable serial);
                                                              ^
./adb/adb_client.h:44:49: error: expected ‘,’ or ‘...’ before ‘type’
 void adb_get_transport(TransportType* _Nullable type, const char* _Nullable* _Nullable serial);
                                             ^
./adb/adb_client.h:50:45: error: expected ‘,’ or ‘...’ before ‘hostname’
 void adb_set_tcp_name(const char* _Nullable hostname);
                                         ^
./adb/adb_client.h:55:61: error: expected ‘,’ or ‘...’ before ‘*’ token
 int adb_send_emulator_command(int argc, const char* _Nonnull* _Nonnull argv,
                                                         ^
./adb/adb_client.h:60:47: error: expected ‘,’ or ‘...’ before ‘error’
 bool adb_status(int fd, std::string* _Nonnull error);
                                           ^
./adb/adb_client.h:63:54: error: expected ‘,’ or ‘...’ before ‘command’
 std::string format_host_command(const char* _Nonnull command, TransportType type,
                                                  ^
./adb/adb_client.h:67:47: error: expected ‘,’ or ‘...’ before ‘feature_set’
 bool adb_get_feature_set(FeatureSet* _Nonnull feature_set, std::string* _Nonnull error);
                                           ^

Похоже, _Nonnull и _Nullable определены в файле ./adb/sysdeps.h

58 // Clang-only nullability specifiers
57 #define _Nonnull
59 #define _Nullable

Похоже, что AOSP 7.1.2 поставляется с gcc 4.8. Кроме того, я заметил, что -Wexit-time-destructors не является частью g++, который я использую, и не является -compatibility_version.

ltecoe@ltecoe:~/imx6solox-yocto-bsp/sources/meta-harris-tools/recipes-connectivity/adb/adb-1.0.36/system/core$ g++ -o ./adb/adb_client{,.cpp} -compatibility_version -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wvla -DADB_REVISION='1.0.36' -std=c++14 -Wexit-time-destructors -I./base/include/ -I./include -lrt -ldl -lpthread
g++: error: unrecognized command line option ‘-compatibility_version’
g++: error: unrecognized command line option ‘-Wexit-time-destructors’

person user3325563    schedule 29.12.2017    source источник


Ответы (1)


_Nonnull и _Nullable являются личными ключевыми словами Clang. Что 2 строки объявлений не выполняются из-за условия #ifdef _WIN32.

Итак, чтобы скомпилировать его с помощью g++ в Linux, поместите эти 2 объявления в другие места, где они будут действовать глобально.

person seamlik    schedule 14.07.2018
comment
Спасибо, что посмотрели. Я попробую это в ближайшем будущем и дам вам знать. - person user3325563; 19.09.2018