Compiler Macros

Predefined macros allow you to guard code with #ifdef and #ifndef preprocessor statements; the macro names begin and end with two underscore characters ‘_’. The __SDSCC__ macro is defined whenever sdscc or sds++ is used to compile source files; it can be used to guard code depending on whether it is compiled by sdscc/sds++ or another compiler, for example GCC.

When sdscc or sds++ compiles source files targeted for hardware acceleration using Vivado HLS, the __SDSVHLS__ macro is defined to be used to guard code depending on whether high-level synthesis is run or not.

The code fragment below illustrates the use of the __SDSCC__ macro to use the sds_alloc() and sds_free() functions when compiling source code with sdscc/sds++, and malloc() and free() when using other compilers.
#ifdef __SDSCC__
#include <stdlib.h>
#include "sds_lib.h"
#define malloc(x) (sds_alloc(x))
#define free(x) (sds_free(x))
In the example below, the __SDSVHLS__ macro is used to guard code in a function definition that differs depending on whether it is used by Vivado HLS to generate hardware or used in a software implementation.
#ifdef __SDSVHLS__
void mmult(ap_axiu<32,1,1,1> A[A_NROWS*A_NCOLS],
           ap_axiu<32,1,1,1> B[A_NCOLS*B_NCOLS],
           ap_axiu<32,1,1,1> C[A_NROWS*B_NCOLS])
void mmult(float A[A_NROWS*A_NCOLS],
           float B[A_NCOLS*B_NCOLS],
           float C[A_NROWS*B_NCOLS])