Post Go back to editing

Designated Initializers don't work in C++11 mode

Designated Initializers works in C and C++ mode, but it don't work in C++11 mode.

Why?

"An_absolute_file_path\file_name.cpp", line 149: cc0040: error: expected an identifier

[0 + 0] { (u32)(&zero0), 0x00000000 }, // 000: zero signal

 ^

"An_absolute_file_path\file_name.cpp", line 149: cc0065: error: expected a ";"

[0 + 0] { (u32)(&zero0), 0x00000000 }, // 000: zero signal

                                                          ^

  • There is nothing about Designated Initializers and C++11 mode.

    Your answer is a formal reply. It's not helping.

  • I use Sharc compiler. There is nothing about that the compiler supports it as an extension in C89 and C++ modes, except for initializing arrays in C++11 mode.

  • Hi,

    For detailed information and usage of Designated Initializers, you can refer in CCES help:
    CrossCoreRegistered Embedded Studio 2.5.0 > SHARCRegistered Development Tools Documentation > C/C++ Compiler Manual for SHARCRegistered Processors > Compiler > C/C++ Compiler Language Extensions > Designated Initializers

    CrossCoreRegistered Embedded Studio 2.5.0 > BlackfinRegistered Development Tools Documentation > C/C++ Compiler and Library Manual for BlackfinRegistered Processors > Compiler > C/C++ Compiler Language Extensions > Designated Initializers

    Please let us know the processor you are working with.


    Also please share the sample project which replicates this issue.

    Regards,

    Kader

  • Hi,

    You can see the below information in the help path we shared:

    This is a standard feature of the ISO/IEC 9899:1999 C standard. The compiler supports it as an extension in C89 and C++ modes, except for initializing arrays in C++11 mode.

    CrossCoreRegistered Embedded Studio 2.5.0 > BlackfinRegistered Development Tools Documentation > C/C++ Compiler and Library Manual for BlackfinRegistered Processors > Compiler > C/C++ Compiler Language Extensions > Designated Initializers

    Let us know the processor you are working with. Also can you please share a sample project which replicates this issue?

     

    Regards,

    Kader

  • Designated initializers are a C99 feature. We've enabled them by default as an extension where possible. Unfortunately there is an overlap between C++11 lambda expressions (new for C++11) and designated initializers syntax. This means designated initializers cannot be used in C++11 mode.

    Regards,

    Stuart.

  • ADI must fix

    CrossCoreRegistered Embedded Studio 2.5.0 > SHARCRegistered Development Tools Documentation > C/C++ Compiler Manual for SHARCRegistered Processors > Compiler > C/C++ Compiler Language Extensions > Designated Initializers

    as

    CrossCoreRegistered Embedded Studio 2.5.0 > BlackfinRegistered Development Tools Documentation > C/C++ Compiler and Library Manual for BlackfinRegistered Processors > Compiler > C/C++ Compiler Language Extensions > Designated Initializers:

    This is a standard feature of the ISO/IEC 9899:1999 C standard. The compiler supports it as an extension in C89 and C++ modes, except for initializing arrays in C++11 mode.

  • -- Ignore the reply below... I see what you're saying, the SHARC documentation is missing the detail regarding C++11. --

    Sorry Eugene I don't understand your point. Are you saying that the documentation isn't correct? It does say that you can't use designated initializers for array initialzations in C++ 11 which is correct. It doesn't document why they can't be used, is that what you would like added to the documentation?

    Regards,

    Stuart. 

  • CCES 2.6.0 C/C++ Compiler Manual for SHARC Processors hasn't the detail about C++11 and Designated Initializers, but CCES 2.6.0 C/C++ Compiler and Library Manual for Blackfin Processors has.

  • The change should get into CCES 2.7.0.

    Regards,

    Stuart.