Macro in different file : Macro Basic « Macro Preprocessor « C / ANSI-C






Macro in different file

//file1.h
#define USD 1

//file2.h
#define UKP 1

//file3
#include <stdio.h>
#include <file1.h> 
#include <file2.h> 

#ifdef USD 
       #define currency_rate 46 
#endif 

#ifdef UKP 
   #define currency_rate 100 
#endif 

main()
{    
  int rs;
  rs = 10 * currency_rate; 
  printf ("%d\n", rs);
}


           
       








Related examples in the same category

1.Use macro in calculation
2.Check if a macro has been defined