[SOLVED] missing ";" compiler error points to wrong place, if preprocessor #define macro() is used directly after

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] missing ";" compiler error points to wrong place, if preprocessor #define macro() is used directly after

    Hi, using SEGGER Embedded studio for ARM Release 3.40.

    Compiler error points to wrong place (headerfile).

    I had an error in my code but the compiler was pointing to a unrealated preprocessor macro in a headerfile.
    It is very confusing.

    Example code that isolates the problem
    -------------------------------
    // Macro without any error
    #define A_MACRO(ERR_CODE) \
    do \
    { \
    } while (0)

    // enum with missing ";" at the end
    enum missingsemicolon_e{
    MISSING_SEMI_COLON
    } // <<<----------- ERROR is here (missing ; )
    // call to macro just after.
    A_MACRO(err_code)
    -------------------------------

    Can somebody confirm this bug?

    Best regards
    Peter
  • Hello Peter,

    Yes the issue is reproducible with the example.
    Embedded Studio is using the ARM gcc and clang compiler so the issue comes from their error handling and not from Embedded Studio itself.
    GCC simply detects it wrong. If you use the same example and switch to clang in project options as compiler, you will get the correct error message:
    "expected ';' after enum"


    This thread will be closed now as this is issue is related to bugs in gcc and not Embedded Studio. For more information we suggest to get in contact with the gcc team at GNU-Projekt.

    Best regards,
    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support contact us per e-mail.
    Alternatively our support ticketing system can be used as well: segger.com/ticket/