This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with #elif

Hello,

I am trying unsuccessfully to use directive compilers such as #ifdef #elif with Keil C v6.12 as follows:

#if defined (TOTO)
#include "toto.h"
#elif defined (TATA)
#include "tata.h"
#elif defined (TITI)
#include "titi.h"
#endif

I think it should work, but it doesn't.

Before I was using :

#if defined (TOTO)
#include "toto.h"
#endif

#if defined (TATA)
#include "tata.h"
#endif

#if defined (TITI)
#include "titi.h"
#endif

But in some cases in my code that is not possible to do so, I have to use a #elif.

If someone has experienced the same problem....

Thank you for your help

Best regards,

Christophe

Parents
  • Hello, thank you for answering me.
    I have compile errors because the file is not included. But I don't have compile errors on #elif statement.

    It was working with :

    #ifdef AA
    #include
    #endif

    #ifdef BB
    #include
    #endif

    #ifdef CC
    #include
    #endif

    But I would like not to test AA, BB or CC. If AA is OK, then not test BB or CC.

    Best regards,

    Christophe

Reply
  • Hello, thank you for answering me.
    I have compile errors because the file is not included. But I don't have compile errors on #elif statement.

    It was working with :

    #ifdef AA
    #include
    #endif

    #ifdef BB
    #include
    #endif

    #ifdef CC
    #include
    #endif

    But I would like not to test AA, BB or CC. If AA is OK, then not test BB or CC.

    Best regards,

    Christophe

Children