Macro Redefinition

 

I believe I have used these 2 routines on several occasions and never had a warning / problem.

When I compile my EA I get the warning "macro redefinition" with line # for line in second routine.  Obviously not critical but would like to understand why the warning is occurring and what to do to overcome / prevent this happening again

//                                                                                         |
//                                                                                         | 
//=================================Draw_my_VLine -- START==================================+                                                                                      |
void Draw_my_VLine(long time_value, string ObjName, color colour)
{  #define WINDOW_MAIN 0    //   NO warning generated for this line 
   if ( ObjectFind(ObjName) == 0 ) ObjectDelete(ObjName);
   ObjectCreate(ObjName, OBJ_VLINE, WINDOW_MAIN,  time_value,0);
   ObjectSetText(ObjName, ObjName, 10, "Times New Roman", colour);   
   ObjectSet(ObjName, OBJPROP_COLOR,colour);
   ObjectSet(ObjName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ObjName, OBJPROP_WIDTH, 2);
   ObjectSet(ObjName, OBJPROP_RAY, False);
   return;
}
//=================================Draw_my_VLine -- END====================================+ 
//                                                                                         |
//                                                                                         |
//================================Draw_my_HLine -- START===================================+
void Draw_my_HLine(double line_value, string ObjName, color colour)
{  #define WINDOW_MAIN 0    //   warning generated for this line "macro redefinition"
   if ( ObjectFind(ObjName) == 0 ) ObjectDelete(ObjName); 
   ObjectCreate(ObjName, OBJ_HLINE, WINDOW_MAIN, Time[0], line_value);
   ObjectSetText(ObjName, ObjName, 10, "Times New Roman", colour);   
   ObjectSet(ObjName, OBJPROP_COLOR,colour);
   ObjectSet(ObjName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ObjName, OBJPROP_WIDTH, 1);
   ObjectSet(ObjName, OBJPROP_RAY, False);
   return;
}
//===================================Draw_my_HLine -- END==================================+

 
try to define it only once at the head of your EA and not within a function.
 
gooly:
try to define it only once at the head of your EA and not within a function.

that's working fine - many thanks

 
gooly: try to define it only once at the head of your EA and not within a function.
Macro's are global from the place defined. They are not within any function.
 
WHRoeder:
gooly: try to define it only once at the head of your EA and not within a function.
Macro's are global from the place defined. They are not within any function.

I know!

But it is my experience that in case of teaching or advising it is better to give a person some room for 'experiments'.

A try-to-do-formulation causes a different approach to solve the problem than a you-must do. The later might increases the dependency on looking for a next advice. Try-to-do increases the feeling I can do it myself - I hope.

 
Global or local - they are precompiler directives, with no relation to the code structure. 
 
DeepThought:
Global or local - they are precompiler directives, with no relation to the code structure. 

Thanks all very much - not even sure I understand all the replies ... now working fine.


As always thanks to all for replies

Reason: