Add compile option to disable floating point usage (#114)
This commit adds the option to disable floating point processing in
QCBOR. To disable, the USEFULBUF_DISABLE_ALL_FLOAT preprocessor macro
needs to be defined.
e.g.:
$ make CMD_LINE="-DUSEFULBUF_DISABLE_ALL_FLOAT"
This removes the capability (and the code) of decoding floating point
types. The type is still recognised, so a meaningful
QCBOR_ERR_ALL_FLOAT_DISABLED error is returned when a floating point value
is encountered in a decoded qcbor. From the encoding interface the
floating point encoding functions are removed.
Change-Id: I371769246f7d83354607de9bce1e7998b8c536a1
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/src/qcbor_encode.c b/src/qcbor_encode.c
index 7c248ef..7f9c169 100644
--- a/src/qcbor_encode.c
+++ b/src/qcbor_encode.c
@@ -1,6 +1,7 @@
/*==============================================================================
Copyright (c) 2016-2018, The Linux Foundation.
Copyright (c) 2018-2021, Laurence Lundblade.
+ Copyright (c) 2021, Arm Limited.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -690,6 +691,7 @@
}
+#ifndef USEFULBUF_DISABLE_ALL_FLOAT
/*
* Public functions for adding a double. See qcbor/qcbor_encode.h
*/
@@ -740,6 +742,7 @@
QCBOREncode_AddFloatNoPreferred(me, fNum);
#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
}
+#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA