You have made the rather common mistake of showing us stuff that has nothing to do with the problem. In essence, you have shown us your assumptions, but obviously your assumptions are wrong or else you would see where the trouble is yourself.

What you need to do is take a definite set of files, compile and run them, make sure they show the problem, then, if you still can't find the solution yourself, post all of those exact files.