Re: [PATCHv2] Macro for testing the version you are compiling with

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 13, 2013 at 12:26 PM, Eric Blake <eblake@xxxxxxxxxx> wrote:
> On 11/13/2013 11:02 AM, Doug Goldstein wrote:
>> Added a macro similar to the GLib's GLIB_CHECK_VERSION so that one can
>> simplydo something like:
>
> s/simplydo/simply do/
>
>>
>>  #if LIBVIRT_CHECK_VERSION(1,1,3)
>>    /* Call function here that appeared in 1.1.3 and newer */
>>    virSomeNewFunction();
>>  #endif
>> ---
>>  include/libvirt/libvirt.h.in | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>
> Closer.
>
>>
>> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
>> index 80b2d78..65f98c6 100644
>> --- a/include/libvirt/libvirt.h.in
>> +++ b/include/libvirt/libvirt.h.in
>> @@ -1466,6 +1466,20 @@ VIR_EXPORT_VAR virConnectAuthPtr virConnectAuthPtrDefault;
>>
>>  #define LIBVIR_VERSION_NUMBER @LIBVIRT_VERSION_NUMBER@
>>
>> +/**
>> + * LIBVIRT_CHECK_VERSION:
>
> Should we document @major, @minor, @micro here, so the doc comments are
> more complete?
>
>> + *
>> + * Macro for developers to easily check what version of the library
>> + * their code is compiling against.
>> + * e.g.
>> + * #if LIBVIR_CHECK_VERSION(1,1,3)
>
> Mismatch between LIBVIRT_ vs. LIBVIR_.  Given that we already expose
> LIBVIR_VERSION_NUMBER, I think the LIBVIR_ prefix is preferred for the
> public interface, and that this example is correct...

Last minute change from v1 because I noticed Daniel called it
LIBVIRT_CHECK_VERSION. I originally had the macro start with LIBVIR.
Its up to you guys what you'd prefer.

>
>> + *   // some code that only works in 1.1.3 and newer
>> + * #endif
>
> Indent the #if and #endif, so that the generated html page represents
> this as a three-line code box.
>
>> + */
>> +#define LIBVIRT_CHECK_VERSION(major,minor,micro) \
>
> ...while the define name has an extra T.
>
> Space after comma.
>
>> +    ((((major) * 1000000) + ((minor) * 1000) + (micro)) <= \
>
> This isn't lisp :)  The following is equivalent, with fewer ():
>
> ((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER)
>
>> +     LIBVIR_VERSION_NUMBER)
>> +
>>  int                     virGetVersion           (unsigned long *libVer,
>>                                                   const char *type,
>>                                                   unsigned long *typeVer);
>>
>
> --
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>



-- 
Doug Goldstein

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]