У меня есть код:
std::array<JNINativeMethod, 26> methods = {
{ "nativeCreate", "(Ljava/lang/String;)J", reinterpret_cast<void*>(&nativeCreate) },
{ "nativeDestroy", "(J)V", reinterpret_cast<void*>(&nativeDestroy) },
...
{ "nativeToggleDebug", "(J)V", reinterpret_cast<void*>(&nativeToggleDebug) }}
};
Это я пытаюсь скомпилировать с помощью компилятора Android NDKs clang 3.4.
Однако этот код дает мне эту ошибку:
jni/JNI.cpp:252:9: error: excess elements in struct initializer
{ "nativeDestroy", "(J)V", reinterpret_cast<void*>(&nativeDestroy) },
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Если я не добавлю еще один набор скобок:
std::array<JNINativeMethod, 26> methods = {{
{ "nativeCreate", "(Ljava/lang/String;)J", reinterpret_cast<void*>(&nativeCreate) },
{ "nativeDestroy", "(J)V", reinterpret_cast<void*>(&nativeDestroy) },
...
{ "nativeToggleDebug", "(J)V", reinterpret_cast<void*>(&nativeToggleDebug) }}
}};
Мне это кажется странным, но после того, как я нашел обсуждение Visual C ++: http://social.msdn.microsoft.com/forums/vstudio/en-US/e5ad8fa5-c9e8-4328-a7fa-af7a47ce2492/initialising-a-stdarray-of-Structs
Я хочу знать, неправильный ли это синтаксис C ++ 11 или просто дефект в clang 3.4.
Связано ли это с ошибкой, упомянутой в Инициализация простых структур с использованием списков инициализаторов с помощью clang