Compiler Macros

Predefined macros allow you to guard code with#ifdefand#ifndefpreprocessor statements; the macro names begin and end with two underscore characters ‘_’. The__SDSCC__macro is defined wheneversdsccorsds++is used to compile source files; it can be used to guard code depending on whether it is compiled bysdscc/sds++or another compiler, for exampleGCC.

Whensdsccorsds++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  #include "sds_lib.h" #define malloc(x) (sds_alloc(x)) #define free(x) (sds_free(x)) #endif
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]) #else void mmult(float A[A_NROWS*A_NCOLS], float B[A_NCOLS*B_NCOLS], float C[A_NROWS*B_NCOLS]) #endif