le_apiFeatures.h

Go to the documentation of this file.
1 /** @file le_apiFeatures.h
2  *
3  * API feature selection for Legato. This file provides a mapping of KConfig selections to API
4  * functions that are available. As an example, if file system support is disabled, then a
5  * compile-time error will be generated if an le_fs function is used.
6  *
7  * Copyright (C) Sierra Wireless Inc.
8  */
9 
10 #ifndef LEGATO_APIFEATURES_INCLUDE_GUARD
11 #define LEGATO_APIFEATURES_INCLUDE_GUARD
12 
13 //--------------------------------------------------------------------------------------------------
14 /**
15  * Mark a function as disabled due to a KConfig selection.
16  *
17  * @param setting Configuration setting name string.
18  */
19 //--------------------------------------------------------------------------------------------------
20 #if (defined(__GNUC__) && !defined(__clang__)) || __has_attribute(error)
21 # define LE_FUNC_DISABLED(setting) \
22  __attribute__((error("Function unavailable due to " setting " configuration")))
23 #elif __has_attribute(enable_if)
24 # define LE_FUNC_DISABLED(setting) \
25  __attribute__((enable_if(0, "Function unavailable due to " setting " configuration")))
26 #else
27 # define LE_FUNC_DISABLED(setting)
28 #endif
29 
30 //--------------------------------------------------------------------------------------------------
31 /**
32  * Macro used to declare that a symbol is part of the "full" Legato API.
33  *
34  * There are two APIs for Legato: "full" and "limited". Linux uses the "full" API and all
35  * functions are available. On other platforms only the "limited" API is supported, and
36  * any attempt to use a "full" api function will lead to a compile error.
37  */
38 //--------------------------------------------------------------------------------------------------
39 #if LE_CONFIG_LINUX
40 # define LE_FULL_API
41 #else
42 # define LE_FULL_API LE_FUNC_DISABLED("LINUX")
43 #endif
44 
45 /// API requires filesystem support.
46 #if LE_CONFIG_FILESYSTEM
47 # define LE_API_FILESYSTEM
48 #else
49 # define LE_API_FILESYSTEM LE_FUNC_DISABLED("FILESYSTEM")
50 #endif
51 
52 #if LE_CONFIG_ENABLE_LE_JSON_API
53 # define LE_API_JSON
54 #else
55 # define LE_API_JSON LE_FUNC_DISABLED("ENABLE_LE_JSON_API")
56 #endif
57 
58 #endif /* end LEGATO_APIFEATURES_INCLUDE_GUARD */