VLFeat - Documentation > C API

# VLFeat.org

Documentation> C API

- Main Page
- Related Pages
- Data Structures
- Files

Preprocssor, library state, etc.

Author
  Andrea Vedaldi

# C preprocessor helpers

VLFeat provides a few C preprocessor macros of general utility. These include stringification (VL_STRINGIFY, VL_XSTRINGIFY) and concatenation (VL_CAT, VL_XCAT) of symbols.

# VLFeat state and configuration parameters

VLFeat has some global configuration parameters that can changed. Changing the configuration is thread unsave (Threading). Use vl_set_simd_enabled to toggle the use of a SIMD unit (Intel SSE code), vl_set_alloc_func to change the memory allocation functions, and vl_set_printf_func to change the logging function.

# Error handling

Some VLFeat functions signal errors in a way similar to the standard C library. In case of error, a VLFeat function may return an error code directly, or an invalid result (for instance a negative file descriptor or a null pointer). Then vl_get_last_error and vl_get_last_error_message can be used to retrieve further details about the error (these functions should be used right after an error has occurred, before any other VLFeat call).

# Memory allocation

VLFeat uses the vl_malloc, vl_realloc, vl_calloc and vl_free functions to allocate memory. Normally these functions are mapped to the underlying standard C library implementations. However vl_set_alloc_func can be used to map them to other implementations. For instance, in MATALB MEX files these functions are mapped to the MATLAB equivalent which has a garbage collection mechanism to cope with interruptions during execution.

# Logging

VLFeat uses the macros VL_PRINT and VL_PRINTF to print progress or debug informations. These functions are normally mapped to the `printf` function of the underlying standard C library. However vl_set_printf_func can be used to map it to a different implementation. For instance, in MATLAB MEX files this function is mapped to `mexPrintf`. Setting the function to `NULL` disables logging.

# Measuring time

VLFeat provides vl_tic and vl_toc as an easy way of measuring elapsed time.