Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#include MACRO
#1
I wonder if you could show some examples of how to use #include MACRO introduced in 1.5.1 as I don't see anything in the wiki

thanks
Reply
#2
Include macro means you can #define MACRO <something> and later do #include MACRO so it will get replaced and do the include properly. This allows dynamically including things even from the command line. For example:
Code:
#define CONCAT(x,y)  x##y
#define TO_STR(x)  #x

#ifndef LANG
#  warning no LANG defined, using default EN
#  define LANG EN
#endif

#include TO_STR(CONCAT(LANG, _lang.bas)


This can be compiled with
Code:
zxbc file.bas -D LANG=ES

which will define the macro LANG with the value es, so the file "ES_lang.bas" will be included instead of "EN_lang.bas" which is the default in this program.

#include MACRO means, MACRO can be any expression that, when resolved, leads to <XXXX> or "XXXX"
Reply
#3
(08-24-2021, 07:41 AM)boriel Wrote: Include macro means you can #define MACRO <something> and later do #include MACRO so it will get replaced and do the include properly. This allows dynamically including things even from the command line. For example:
Code:
#define CONCAT(x,y)  x##y
#define TO_STR(x)  #x

#ifndef LANG
#  warning no LANG defined, using default EN
#  define LANG EN
#endif

#include TO_STR(CONCAT(LANG, _lang.bas)


This can be compiled with
Code:
zxbc file.bas -D LANG=ES

which will define the macro LANG with the value es, so the file "ES_lang.bas" will be included instead of "EN_lang.bas" which is the default in this program.

#include MACRO means, MACRO can be any expression that, when resolved, leads to <XXXX> or "XXXX"

Thank you ! :-)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)