[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Macro to check header define value
From: |
emmanuel |
Subject: |
Re: Macro to check header define value |
Date: |
Fri, 22 Jan 2010 12:36:05 +0100 |
Le jeu 21/01/10 17:58, "Peter Johansson" address@hidden a écrit:
> Hi emannuel,
>
> emmanu
> address@hidden wrote:
> Hi,
> >
> > my software uses an extern library which has its
> version number in it header.h like following:
> #define LIB_VERSION 424242
> >
> > I need to check this version number (because the API
> was changed and this introduced an incompatibility).
>
> > I think about something like
> AC_CHECK_DEFINE_VALUE... bug nothing like that seems to exist.
>
> > Does someone knows how to do that?
> >
> >
> I would use a more low-level macro such as AC_COMPILE_IFELSE, e.g., as
>
follows (not tested)
>
> AC_COMPILE_IFELSE(
> [AC_LANG_PROGRAM(address@hidden:@include <header.h>],
> [ #if LIB_VERSION >= 424242
> // OK
> #else
> # error version too old
> #endif
> ])
> ],
> [ACTION-IF_OK], ACTION-IF_NOT_OK])
>
> Cheers,
> Peter
Thank you Peter, you helped me a lot.
This is code I have done to check libmicrohttpd version:
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <microhttpd.h>
]],
[[
#if MHD_VERSION >= 0x00040000
// MHD_VERSION is high enough
#else
# MHD_VERSION is to low
#endif
]])],
[], [AC_MSG_ERROR([[The libmicrohttpd
version must be 0.4.0 or higher.]])])
Regards
Emmanuel