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

How I can predefine C macros from commad line in A51?

I want select configuration from command line.
In A51 I cann't define __CONFIG__ as C macros.
"config.h" include in C and ASM files.
config.h

#ifndef _CONFIG_H
#define _CONFIG_H

#define CONFIG_DEBUG        0
#define CONFIG_TEST         1
#define CONFIG_RELEASE      2

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#if     __CONFIGx__ == CONFIG_DEBUG

#define DEBUG                   1
#define xTECH_ROM               1
#define ENABLE_EPROM            1
#define LANG                    UKR
#define _RESTAURANT_MODE        1
#define PRINT_LOGO_FROM_ROM     1

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#elif   __CONFIGx__ == CONFIG_TEST

#define SIMULATOR               1

#define DEBUG                   1
#define xTECH_ROM               1
#define ENABLE_EPROM            1
#define LANG                    UKR
#define _RESTAURANT_MODE        1
#define INTERNAL_TEST           1
#define xPRINT_LOGO_FROM_ROM    1

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#elif   __CONFIGx__ == CONFIG_RELEASE

#define xDEBUG                  1
#define xTECH_ROM               1
#define ENABLE_EPROM            1
#define LANG                    UKR
#define _RESTAURANT_MODE        1
#define xPRINT_LOGO_FROM_ROM    1

#endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#endif

Parents
  • I'm quite sure you can't do that directly. There's no access at all from the Ax51 command line to the C preprocessor built into it.

    You *can* define Ax51 macros, though, and those you can then use to trigger #define statements. In a nutshell:

    $IF (A51_CONFIG_TEST)
    #define __CONFIGx__ CONFIG_TEST
    $ELIF (A51_CONFIG_DEBUG)
    #define __CONFIGX__ CONFIG_DEBUG
    $ENDIF
    

    You can then pre-set A51_CONFIG_* from the Ax51 command line, even through the IDE.

    And a technical side note: your macro names __CONFIGx__ and _CONFIG_H are forbidden fruit. They belong into the implementor's name space, i.e. they are never allowed to be #define'd by the author of application code. Don't use any names beginning with underscores if you want to avoid nasty problems in the future.

Reply
  • I'm quite sure you can't do that directly. There's no access at all from the Ax51 command line to the C preprocessor built into it.

    You *can* define Ax51 macros, though, and those you can then use to trigger #define statements. In a nutshell:

    $IF (A51_CONFIG_TEST)
    #define __CONFIGx__ CONFIG_TEST
    $ELIF (A51_CONFIG_DEBUG)
    #define __CONFIGX__ CONFIG_DEBUG
    $ENDIF
    

    You can then pre-set A51_CONFIG_* from the Ax51 command line, even through the IDE.

    And a technical side note: your macro names __CONFIGx__ and _CONFIG_H are forbidden fruit. They belong into the implementor's name space, i.e. they are never allowed to be #define'd by the author of application code. Don't use any names beginning with underscores if you want to avoid nasty problems in the future.

Children