I need a compile time check for what version of glibc will be used.
The only compile time checks (ie #defines) I can find return the glibc date (__GLIBCXX__) and correspondence between the date and version seems iffy. How do you check at compile time for the version of glibc that will be used?
My code will compile and run on several systems, including a very old one. In particular I am interested in using malloc_info (see http://man7.org/linux/man-pages/man3/malloc_info.3.html). This was added to glibc in version 2.10. The program will be used on the same (or an identical system) it was built on.
I think what you’re looking for is
__GLIBC__and__GLIBC_MINOR__, which represent anintof the major and minor version numbers of the GNU C Library. Have a look at this(archive link) for more details.So if
__GLIBC__is greater than 2, or__GLIBC__is equal to 2 and__GLIBC_MINOR__is greater than or equal to 10, thenmalloc_info()should work.