0

我正在尝试在此存储库中编译源代码:

https://github.com/MaartenBaert/ssr

以及这个特定源文件的编译错误:

https://github.com/MaartenBaert/ssr/blob/master/src/GUI/PageOutput.cpp

出现以下错误:

../../src/GUI/PageOutput.cpp:66: error: no match for ‘operator=’ in ‘((PageOutput*)this)->PageOutput::m_containers = {{"Matroska (MKV)", "matroska", {"mkv"}, "Matroska files (*.mkv)", {(PageOutput::enum_video_codec)0u, (PageOutput::enum_video_codec)1u, (PageOutput::enum_video_codec)2u}, {(PageOutput::enum_audio_codec)0u, (PageOutput::enum_audio_codec)1u, (PageOutput::enum_audio_codec)2u, (PageOutput::enum_audio_codec)3u}}, {"MP4", "mp4", {"mp4"}, "MP4 files (*.mp4)", {(PageOutput::enum_video_codec)0u}, {(PageOutput::enum_audio_codec)0u, (PageOutput::enum_audio_codec)1u, (PageOutput::enum_audio_codec)2u}}, {"WebM", "webm", {"webm"}, "WebM files (*.webm)", {(PageOutput::enum_video_codec)1u}, {(PageOutput::enum_audio_codec)0u}}, {"OGG", "ogg", {"ogg"}, "OGG files (*.ogg)", {(PageOutput::enum_video_codec)2u}, {(PageOutput::enum_audio_codec)0u}}, {"Other...", "", <brace-enclosed initializer list>(), "", <brace-enclosed initializer list>(), <brace-enclosed initializer list>()}}’
/usr/lib/gcc/x86_64-redhat-linux6E/4.4.6/../../../../include/c++/4.4.6/bits/vector.tcc:156: note: candidates are: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = PageOutput::ContainerData, _Alloc = std::allocator<PageOutput::ContainerData>]
/usr/lib/gcc/x86_64-redhat-linux6E/4.4.6/../../../../include/c++/4.4.6/bits/stl_vector.h:336: note:                 std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = PageOutput::ContainerData, _Alloc = std::allocator<PageOutput::ContainerData>]
/usr/lib/gcc/x86_64-redhat-linux6E/4.4.6/../../../../include/c++/4.4.6/bits/stl_vector.h:356: note:                 std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = PageOutput::ContainerData, _Alloc = std::allocator<PageOutput::ContainerData>]
make[2]: *** [simplescreenrecorder-PageOutput.o] Error 1

有问题的代码,格式正确:

m_containers = {
        {"Matroska (MKV)", "matroska", {"mkv"}, "Matroska files (*.mkv)",
                {VIDEO_CODEC_H264, VIDEO_CODEC_VP8, VIDEO_CODEC_THEORA},
                {AUDIO_CODEC_VORBIS, AUDIO_CODEC_MP3, AUDIO_CODEC_AAC, AUDIO_CODEC_UNCOMPRESSED}},
        {"MP4", "mp4", {"mp4"}, "MP4 files (*.mp4)"     ,
                {VIDEO_CODEC_H264},
                {AUDIO_CODEC_VORBIS, AUDIO_CODEC_MP3, AUDIO_CODEC_AAC}},
        {"WebM", "webm", {"webm"}, "WebM files (*.webm)"   ,
                {VIDEO_CODEC_VP8},
                {AUDIO_CODEC_VORBIS,}},
        {"OGG", "ogg", {"ogg"}, "OGG files (*.ogg)"     ,
                {VIDEO_CODEC_THEORA},
                {AUDIO_CODEC_VORBIS}},
        {"Other...", "", {}, "", {}, {}},
};

我更像是一个 C 程序员,我的 C++ 有点生疏。我四处搜索,错误很常见,但还无法准确找出这个错误。

4

1 回答 1

3

GCC 4.4.6 不支持将 astd::initializer_list作为参数,因此无法进行列表分配。但是,如果无法升级 GCC,则很容易解决:

PageOutput::ContainerData temp[] = {
        {"Matroska (MKV)", "matroska", {"mkv"}, "Matroska files (*.mkv)",
                {VIDEO_CODEC_H264, VIDEO_CODEC_VP8, VIDEO_CODEC_THEORA},
                {AUDIO_CODEC_VORBIS, AUDIO_CODEC_MP3, AUDIO_CODEC_AAC, AUDIO_CODEC_UNCOMPRESSED}},
        {"MP4", "mp4", {"mp4"}, "MP4 files (*.mp4)"     ,
                {VIDEO_CODEC_H264},
                {AUDIO_CODEC_VORBIS, AUDIO_CODEC_MP3, AUDIO_CODEC_AAC}},
        {"WebM", "webm", {"webm"}, "WebM files (*.webm)"   ,
                {VIDEO_CODEC_VP8},
                {AUDIO_CODEC_VORBIS,}},
        {"OGG", "ogg", {"ogg"}, "OGG files (*.ogg)"     ,
                {VIDEO_CODEC_THEORA},
                {AUDIO_CODEC_VORBIS}},
        {"Other...", "", {}, "", {}, {}},
};

m_containers.assign(std::begin(temp), std::end(temp));

我不记得std::begin/end该版本中是否存在,但否则它们很容易实现:

template<typename T, std::size_t N>
T *begin(const T(&arr)[N]) {return arr;}

template<typename T, std::size_t N>
T *end(const T(&arr)[N]) {return arr + N;}
于 2013-08-08T00:42:14.637 回答