Ziggi Temat założony przez niniejszego użytkownika |
Problem z kompilacją rozszerzenie PHP w środowisku VS2012 » 2015-09-21 17:03:42 Witam,
W zakresie języków C / C++ jestem absolutnym lamerem, ale potrzeba jest wyzwaniem...
Potrzebuję pilnie skompilować rozszerzenie PHP 5.6.x o nazwie Pinba:
https://github.com/tony2001/pinba_extension
Rozszerzenie to używa Google Protocol Buffers:
https://github.com/google/protobuf
Już kilka rozszerzeń PHP udawało mi się samodzielnie kompilować, ale tym razem mam problem. Kompiluję składkę pod VS2012 x64 Cross Tools Command Prompt i kompilacja wykłada mi się tutaj:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\nmake.exe" /I /nologo "php_pinba.dll
pinba-pb-c.c ext\pinba\pinba-pb-c.c(54) : error C2059: syntax error : '.' ext\pinba\pinba-pb-c.c(72) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(82) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(92) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(102) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(112) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(122) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(132) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(142) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(152) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(162) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(172) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(182) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(192) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(202) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(212) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(222) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(232) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(242) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(252) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(262) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(272) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(282) : error C2059: syntax error : ',' ext\pinba\pinba-pb-c.c(316) : error C2059: syntax error : '.'
Ktoś może pomóc? - Zupełnie nie rozumiem o co gadowi może chodzić :-( |
|
Monika90 |
» 2015-09-21 18:12:51 Ta wersja kompilatora Microsoftu nie umie kompilować C99. Możesz spróbować z najnowszą wersją, a najlepiej użyć MinGW-W64. |
|
Ziggi Temat założony przez niniejszego użytkownika |
Dzięki! » 2015-09-22 14:12:32 Tak, też to już sam wcześniej zauważyłem.
Może potrafisz pomóc jak przerobić strukturę w rodzaju na format C89?:
static const ProtobufCFieldDescriptor pinba__request__field_descriptors[23] = { { .name = "hostname", .id = 1, .label = PROTOBUF_C_LABEL_REQUIRED, .type = PROTOBUF_C_TYPE_STRING, .quantifier_offset = 0, .offset = PROTOBUF_C_OFFSETOF(Pinba__Request, hostname), .descriptor = NULL, .default_value = NULL, }, { .name = "server_name", .id = 2, .label = PROTOBUF_C_LABEL_REQUIRED, .type = PROTOBUF_C_TYPE_STRING, .quantifier_offset = 0, .offset = PROTOBUF_C_OFFSETOF(Pinba__Request, server_name), .descriptor = NULL, .default_value = NULL, },
[tutaj jeszcze kilka takich bloków]
};
Gdzie w nagłówku jest zadeklarowane:
typedef struct _ProtobufCFieldDescriptor ProtobufCFieldDescriptor; struct _ProtobufCFieldDescriptor { const char *name; uint32_t id; ProtobufCLabel label; ProtobufCType type; unsigned quantifier_offset; unsigned offset; const void *descriptor; /* for MESSAGE and ENUM types */ const void *default_value; /* or NULL if no default-value */ protobuf_c_boolean packed;
unsigned reserved_flags; void *reserved2; void *reserved3; };
i dalej:
/* --- querying the descriptors --- */
PROTOBUF_C_API const ProtobufCFieldDescriptor * protobuf_c_message_descriptor_get_field_by_name (const ProtobufCMessageDescriptor *desc, const char *name); PROTOBUF_C_API const ProtobufCFieldDescriptor * protobuf_c_message_descriptor_get_field (const ProtobufCMessageDescriptor *desc, unsigned value); |
|
mateczek |
skoro wiesz, że masz zły kompilator to go zmień!!! » 2015-09-22 18:45:36 Przy przeróbce mogą pojawić się problemy. Tu masz całą 23 elementową tablicę zainicjalizowaną w sposób charakterystyczny dla nowego standardu !!!I kto wie czy to tylko w tym miejscu:P. Problem jest taki, że sarszy standard nie obsługiwał inicjalizacji z użyciem nawiasów klamrowych. Musiał byś ręcznie wypełnić wszystkie pola w sposób jak poniżej. I jeszcze miejsce gdzie ten kod inicjalizacji miałby się znajdować też jest ważne. pinba__request__field_descriptors[ 0 ].name = "hostname"; pinba__request__field_descriptors[ 0 ].id = 2;
pinba__request__field_descriptors[ 23 ].name = "ble"; pinba__request__field_descriptors[ 0 ].id = 23;
|
|
Monika90 |
» 2015-09-22 20:12:22 Problem jest taki, że sarszy standard nie obsługiwał inicjalizacji z użyciem nawiasów klamrowych. |
Nieprawda. struct X { int x; const char * y; float z; };
struct X x = { .z = 1.1, .x = 2, .y = "abc" };
struct X x = { 2, "abc", 1.1 };
|
|
mateczek |
to pewnikiem coś pokręciłem » 2015-09-22 22:06:15 Ale jak ja zaincializuje konterner w ten sposób Qlist < int > tablica = { 1, 4, 5, 6 };
to mnie się zawsze pluje o włączenie standardu c++11 I dopiero jak do projektu dodam config+=c++11
kompiluje się poprawnie (QtCreator i kompilator gcc) |
|
Monika90 |
» 2015-09-22 23:05:50 QList<int> to nie jest agregat, więc nie mógł być inicjalizowany w ten sposób przed C++11, a struct _ProtobufCFieldDescriptor to jest agregat więc mógł. Poza tym C to nie jest C++.
|
|
« 1 » |