method to avoid global variables

I want to know method, How to avoid global variable in c microcontroller programing? or method to make global variable invisible.
Is there any perticular functions in built in c library?, that could be supportive to avoid global variables or hide global variables.

Parents
  • I don't know if I've understood you correctly, but you might consider these options:

    1) Use a static local variable within a function. It will retain its value between calls to that function but be 'invisible' to the rest of the program.

    2) Use a static variable at file scope (ie declared outwith all functions in the source file). It will be 'invisible' outside that source file.

Reply
  • I don't know if I've understood you correctly, but you might consider these options:

    1) Use a static local variable within a function. It will retain its value between calls to that function but be 'invisible' to the rest of the program.

    2) Use a static variable at file scope (ie declared outwith all functions in the source file). It will be 'invisible' outside that source file.

Children
More questions in this forum