This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to reduce crowd in the main file?

I want to ask a question.

The codes seem too complicated in main file. I created new sources and header files and carried some code into the new sources and header file from main file. For instance it was timer settings and timer handler function in the main files. I carried these into the new sources files.. But after that, my timers are didn't work correctly. For example, although the timers are stopped, they continue to run. however, such a problem did not occur when all the code was written in the main file. what is the reason of this? I want to reduce clutter in the main file. is not it possible?

Parents
  • Of course it's possible to take stuff out of the main.c file and move it into another - that's just standard 'C' refactoring.

    c-faq.com/.../decldef.html

    But, as with any other changes to existing code, you have to have a full understanding of what the existing code is doing and how it works before you start changing it.

    Did you get any compiler warnings?

    If your code doesn't work, then you need to look at how it was working before, and compare that to what your new code is actually doing.

    Step both versions in the debugger.

    Compare & contrast.

    k correctly. For example, although the timers are stopped, they continue to run.

    So you must have missed something in the stopping

Reply
  • Of course it's possible to take stuff out of the main.c file and move it into another - that's just standard 'C' refactoring.

    c-faq.com/.../decldef.html

    But, as with any other changes to existing code, you have to have a full understanding of what the existing code is doing and how it works before you start changing it.

    Did you get any compiler warnings?

    If your code doesn't work, then you need to look at how it was working before, and compare that to what your new code is actually doing.

    Step both versions in the debugger.

    Compare & contrast.

    k correctly. For example, although the timers are stopped, they continue to run.

    So you must have missed something in the stopping

Children
Related