including different versions of glib headers
If there are two source files a.c and b.c: a.c includes the glib.h of glib-2.6.6 and b.c includes glib.h of glib-2.12
Then I compile them and link them together a开发者_运维百科nd generate target program. Assume that a.c is not using any new feature introduced in after v2.6, will including different version of headers cause any problem? If so, when will such problem happen?
It shouldn't cause a problem. That's because GLib maintains API compatibility for all versions in the 2.x series. Whatever version of the headers you use to compile your program, you can link to any version of the library, as long as you aren't using any features not present in that version of the library.
However, you seem to be making your life needlessly difficult:
I'm using a Makefile that can specify the root directory of GLiB and using
#include "glib.h"
in the code. I have multiple versions of glib headers installed.
Why on earth would you want to do that??
See this comparison table for Glib versions. There are some low-severity API/ABI changes done between 2.6.6 and 2.12.0 versions.
...
精彩评论