Add macro M_IF_FUNCOBJ to handle conditional expression if the function object is defined

This commit is contained in:
Patrick Pelissier committed 2020-05-05 23:34:12 +02:00
1 parent 0ac6a53fe9
commit 9ba2de4b70
2 files changed
+13 -1

No files matched your search

+9
View File
@@ -1263,6 +1263,15 @@ extern void m_no_default_function(void) __attribute__((error("The requested op
#define M_NDEBUG_TEST 0 #define M_NDEBUG_TEST 0
#define M_IF_DEBUG(a) M_IF(M_TEST_NDEBUG_P())(,a) #define M_IF_DEBUG(a) M_IF(M_TEST_NDEBUG_P())(,a)
/* If the Function Object is included, expands the code,
otherwise do nothing.
M_FUNCOBJ_IS_NOT_DEFINED is defined to 0.
NOTE: M_IF is the variable is not defined assummes yes.
*/
#define M_IF_FUNCOBJ(a) M_IF(M_FUNCOBJ_IS_NOT_DEFINED)( ,a)
/* Helper macro to redefine a function with a default value : /* Helper macro to redefine a function with a default value :
If there is only one variable as the __VA_ARGS__, print If there is only one variable as the __VA_ARGS__, print
__VA_ARGS__ then ', value', instead only __VA_ARGS__. __VA_ARGS__ then ', value', instead only __VA_ARGS__.
+4 -1
View File
@@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef MSTARLIB_FUNCOBJ_H #ifndef MSTARLIB_FUNCOBJ_H
#define MSTARLIB_FUNCOBJ_H 1 #define MSTARLIB_FUNCOBJ_H
#include "m-core.h" #include "m-core.h"
@@ -70,6 +70,9 @@
/********************************** INTERNAL ************************************/ /********************************** INTERNAL ************************************/
/********************************************************************************/ /********************************************************************************/
/* To be used by M_IF_FUNCOBJ macro */
#define M_FUNCOBJ_IS_NOT_DEFINED 0
/* Design Constraints: /* Design Constraints:
* callback SHALL be the first member of the structures in all the definitions. * callback SHALL be the first member of the structures in all the definitions.
* *