cvlfeat

C functions with two round brackets pairs?


I'm sorry for the bad title, but nothing better came to my mind apart from "I don't understand this code". Please, feel free to propose a modification.

I'm reading this code. I've never seen a C function like this one:

static void
VL_XCAT(_vl_vlad_encode_, SFX)
(TYPE * enc,
 TYPE const * means, vl_size dimension, vl_size numClusters,
 TYPE const * data, vl_size numData,
 TYPE const * assignments,
 int flags)
{
    // function body
}

In particular I'm confused by (_vl_vlad_encode_, SFX). Up to know, all the functions headers that I've seen had only one "pair of round brackets" (the function's parameters), while here there are two pairs.

What does it mean the first one? I think that this is linked to later calls _vl_vlad_encode_f and _vl_vlad_encode_d, which don't appears anywhere else in the library code, but I can't understand how they're connected.


Solution

  • VL_XCAT is a macro usually used to concatenate two tokens. (A ## B) which means it'll create a token from both arguments which is: _vl_vlad_encode_ and SFX - is probably define for type of floating point variable used (double/float)

    I would say this'll choose between double and float function to use and use _vl_vlad_encode_f or _vl_vlad_encode_d based on defines.

    So if

    #define SFX d
    

    it'll create _vl_vlad_encode_d after processing this line.