#ifdef - cannot 2 level?

Posted By: Grat

#ifdef - cannot 2 level? - 02/05/18 09:39

Hi,

in this code:
Code:
//#define ALL_SYMBOL
//#define INDEX


#define _LONG 1
#define _SHORT 2
#define _WRONG -999

#define SAVE1 AlgoVar[0]
#define SAVE2 AlgoVar[1]
#define E_TRADE_L AlgoVar[2]
#define E_TRADE_S AlgoVar[3]

#ifdef ALL_SYMBOL
	#define SYMBOLS "EUR/USD","AUD/USD","USD/JPY","USD/CAD","GBP/USD"
	#define SYM1 "AUD/CAD","AUD/CHF","AUD/JPY","AUD/NZD","CAD/JPY","EUR/AUD","EUR/CAD"
	#define SYM2 "EUR/GBP","EUR/JPY","EUR/NZD","GBP/AUD","GBP/JPY","GBP/NZD","NZD/USD"
	#define SYMBOLS SYM1,SYM2,"USD/JPY","GBP/USD","EUR/USD","USD/CAD","AUD/USD"
	#define ALGOS "M15","H1","H4"
	#define BASE 15

#else
	#ifdef INDEX
		#define SYMBOLS "GER30"
		//,"NAS100","SPX500","UK100","US30"
		#define ALGOS "M15"
		#define BASE 5

	#else 
		#define SYMBOLS "EUR/USD"
		#define ALGOS "M15"
		#define BASE 15

	#endif
#endif



SYMBOLS not "EUR/USD" but "GER30". In the preprocessor cannot be included #ifdef inside other?

version: 1.74.8
Posted By: Grat

Re: #ifdef - cannot 2 level? - 02/05/18 12:08

code must be rewrite:

Code:
#ifdef INDEX
	#define SYMBOLS "GER30"
	//,"NAS100","SPX500","UK100","US30"
	#define ALGOS "M15"
	#define BASE 5
#endif

#ifdef ALL_SYMBOL
	#define SYM1 "AUD/CAD","AUD/CHF","AUD/JPY","AUD/NZD","CAD/JPY","EUR/AUD","EUR/CAD"
	#define SYM2 "EUR/GBP","EUR/JPY","EUR/NZD","GBP/AUD","GBP/JPY","GBP/NZD","NZD/USD"
	#define SYMBOLS SYM1,SYM2,"USD/JPY","GBP/USD","EUR/USD","USD/CAD","AUD/USD"
	#define ALGOS "M15","H1","H4"
	#define BASE 15

#endif

#ifdef SIMPLE
		#define SYMBOLS "EUR/USD"
		#define ALGOS "M15"
		#define BASE 15

#endif

Posted By: jcl

Re: #ifdef - cannot 2 level? - 02/05/18 17:59

The C preprocessor allows nested defines. They they are used all the time in lite-C, so you can also use them in scripts.
Posted By: Grat

Re: #ifdef - cannot 2 level? - 02/06/18 14:17

Try this, If nothing defined, print GER30 not EUR/USD


Description: Test
Attached File
test_preprocesor.c  (87 downloads)
Posted By: jcl

Re: #ifdef - cannot 2 level? - 02/06/18 14:38

Try replacing INDEX with GRAT_INDEX wink

When defining something, check in the headers if it is not already defined. Or add your name to any define - then you're on the safe side.
© 2024 lite-C Forums