XCORE SDK
XCORE Software Development Kit
api.h
1 // Copyright 2022 XMOS LIMITED.
2 // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 
4 #pragma once
5 
6 
7 #if defined(__cplusplus)
8 # define FROM_C 0
9 # define FROM_CPP 1
10 # define FROM_XC 0
11 #elif defined(__XC__)
12 # define FROM_C 0
13 # define FROM_CPP 0
14 # define FROM_XC 1
15 #else //no explicit definitions for C files
16 # define FROM_C 1
17 # define FROM_CPP 0
18 # define FROM_XC 0
19 #endif
20 
21 // I'd rather call this `C_API`, but there's currently an issue in lib_xs3_math
22 // where it defines `C_API` without checking whether it's already defined. That
23 // creates problems depending on the order in which headers are included.
24 #ifndef MA_C_API
25 // XC doesn't support marking individual functions as 'extern "C"`. It requires
26 // use of the block notation.
27 # if FROM_C || FROM_XC
28 # define MA_C_API
29 # else
30 # define MA_C_API extern "C"
31 # endif
32 #endif
33 
34 
35 #ifndef C_API_START
36 # if FROM_XC
37 # define C_API_START extern "C" {
38 # else
39 # define C_API_START
40 # endif
41 #endif
42 
43 
44 #ifndef C_API_END
45 # if FROM_XC
46 # define C_API_END }
47 # else
48 # define C_API_END
49 # endif
50 #endif