Forum Discussion
Altera_Forum
Honored Contributor
21 years agoconditional compilation ?
Hello. I'm working with two kits of development NIOSII. I wish to use the following conditional compilation in a common file (as user.h) : // --- choice of board ---------------...
Altera_Forum
Honored Contributor
21 years agoyes that's it
adresse_mac_ethernet will be defined in all files which include your user.h, the flag FLAG_ADRESSE_MAC_ETHERNET does not prevent this. it's better to put the definition of variables in .c files and a extern declaration for it in the header. eg file: user.h ------------------------------------------------------------------------------ // --- choice of board ---------------------------------- # define NIOSII_1 //#define NIOSII_2 extern const char adresse_mac_ethernet[6]; ------------------------------------------------------------------------------ file: user.c ------------------------------------------------------------------------------# ifdef NIOSII_1# warning "******************NIOSII_1 defined" const char adresse_mac_ethernet[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06} ;# endif // NIOSII_1 # ifdef NIOSII_2# warning "************** NIOSII_2 defined" const char adresse_mac_ethernet[6] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16} ;# endif // NIOSII_2