help with clang error: array initializer must be an initializer list

Titus von Boxberg titus at v9g.de
Thu Sep 5 02:24:55 PDT 2013


Am 05.09.2013 09:21, schrieb Mojca Miklavec:
> Hi,
>
> I'm not really a maintainer, but for the bunch of wxWidgets updates I
> had to fiddle a bit with Code::Blocks.
>
> Jeremy asked me if it was possible to make the software compile with
> clang. I fixed one compile error (which has already been fixed
> upstream), but I'm stuck with the following:
>
> librariesdlg.cpp:93:7: error: array initializer must be an initializer list
>      , m_WorkingCopy(knownLibraries)
>        ^
> 1 error generated.
>
>
> I do know some C/C++, but I don't know how to fix that problem. Below
> are some possibly relevant chunks of the code that could provide a
> clue.
>
> (I reported the bug upstream:
> http://developer.berlios.de/bugs/?func=detailbug&bug_id=19111&group_id=5358)
>
>
> enum LibraryResultType
> {
>      rtDetected = 0,     ///< \brief Cnofiguration detected by lib_finder
>      rtPredefined,       ///< \brief Predefined configuration
>      rtPkgConfig,        ///< \brief Library provided by pkg-config
>      ///////
>      rtCount,            ///< \brief Here will be the number of result types
>      rtUnknown = -1      ///< \brief Used for unknown result types
> };
>
> class ResultMap { ... }
> typedef ResultMap TypedResults[rtCount];
>
> class LibrariesDlg: public wxScrollingDialog
> {
>    ...
>    private:
>      TypedResults& m_KnownLibraries;
>      TypedResults m_WorkingCopy;
>    ...
> }
>
> LibrariesDlg::LibrariesDlg(wxWindow* parent, TypedResults& knownLibraries)
>      : m_KnownLibraries(knownLibraries)
>      , m_WorkingCopy(knownLibraries)
>      , m_SelectedConfig(0)
>      , m_WhileUpdating(false)
> {
>    ...
> }
>
>
> librariesdlg.cpp:93:7: error: array initializer must be an initializer list
>      , m_WorkingCopy(knownLibraries)
>        ^
> 1 error generated.
>
>
Hi Mojca,

you could try

#include <algorithm>

LibrariesDlg::LibrariesDlg(wxWindow* parent, TypedResults& knownLibraries)
     : m_KnownLibraries(knownLibraries)
// do no use    , m_WorkingCopy(knownLibraries)
// ...

{
std::copy(m_KnownLibraries, 
m_KnownLibraries+sizeof(m_WorkingCopy)/sizeof(m_WorkingCopy[0]), 
m_WorkingCopy);
// ...
}

HTH.
Regards
Titus




More information about the macports-dev mailing list