Hi Akshath,
a good approach to avoid such global declarations is to encapsulate the necessary functionality within a class. So all declarations can be made within your methods or as member attributes of the class.
If you still need some global declarations in your programs/includes there exists the pseudo comment #EC NEEDED (or pragma ##NEEDED since 7.02) to hide the messages. But the usage of that pseudo comments or pragmas should be avoided if possible.
Regards,
Florian