Compling on a higher version and executing on a lower version
I am a newbie to Linux and am trying to write some code to collect system related info from the kernel.
I have provide to support for Red Hat Linux release 6.2 (Zoot) and Red Hat Linux release 7.2 (Enigma) which have Kernel 2.2.14-6.1.1 on an i686 and Kernel 2.4.7-10 on an i686 respectively.
I am using the sysinfo system call and struct sysinfo to achieve this. As it's known that the size and content of struct sysinfo has changed across these platforms.
To have only one library work on both the OS flavors, I plan to compile my code on 7.2 and execute it on both 7.2 and 6.2. I have been doing this and seems to be working fine for me. Incidentally, yesterday while discussing with one of my colleagues, he pointed out that this is not the right way to do it namely "Compiling on a higher version and running on a lower version" is not the path to follow.
I am aware that "Compiling on lower and running on higher" is a supported path and I did give it a thought before implementation but as in my code in 6.2 I do not access any of the variables which are not available and access them only in 7.2. Also, I have not faced any problems as yet but now after him pointing it out am a bit curious to know if I can go ahead in the same manner or should have to executables/libraries for both the OS.
Please provide your views and inputs.