-
Problem report
-
Resolution: Unresolved
-
Trivial
-
None
-
2.2.24rc1, 3.0.26rc1, 4.0.6rc1, 4.2.0beta1
-
Sprint 56 (Sep 2019), Sprint 55 (Aug 2019), Sprint 51 (Apr 2019), Sprint 54 (Jul 2019), Sprint 57 (Oct 2019), Sprint 58 (Nov 2019), Sprint 59 (Dec 2019), Sprint 60 (Jan 2020), Sprint 61 (Feb 2020), Sprint 62 (Mar 2020), Sprint 63 (Apr 2020), Sprint 64 (May 2020), Sprint 65 (Jun 2020), Sprint 66 (Jul 2020), Sprint 67 (Aug 2020)
-
0.25
Steps to reproduce:
- Download Zabbix sources or check out from repository
- Navigate to src/modules/dummy
- Comment out
#include "sysinc.h"
leaving just
#include "module.h"
- Try to build module: $ make
Result:
Tons of compilation errors.
Expected:
Successful compilation.
Speculations:
This happens because module.h depends on zbxtypes.h, and zbxtypes.h in turn (implicitly!) depends on lots of system headers. So the only way to compile loadable module is to
#include "sysinc.h"
before(!)
#include "module.h"
But that's not the end of the story because sysinc.h includes system headers conditionally with conditional variables defined in another header(!!!) config.h which is generated by configure script. So one has to run $ ./configure before even attempting to build poor dummy module.
I think this is unacceptable. Module authors need to be quite creative to work around that and this puts extra stress on build systems and continuous integration. The only reason to
#include "zbxtypes.h"
in module.h is definition of zbx_uint64_t:
#if defined(_WINDOWS) /* ... (irrelevant while loadable modules are only available on UNIX platforms) */ #else /* _WINDOWS */ /* ... */ # define zbx_uint64_t uint64_t /* ... */ #endif /* _WINDOWS */
My suggestion is to provide definition of zbx_uint64_t in module.h if it is used outside of Zabbix:
Index: include/module.h =================================================================== --- include/module.h (revision 89838) +++ include/module.h (working copy) @@ -20,7 +20,10 @@ #ifndef ZABBIX_MODULE_H #define ZABBIX_MODULE_H -#include "zbxtypes.h" +#ifndef zbx_uint64_t +# include <stdint.h> +# define zbx_uint64_t uint64_t +#endif #define ZBX_MODULE_OK 0 #define ZBX_MODULE_FAIL -1
Since stdint.h is part of C99, this should cover most of use cases.
With explicit inclusion of necessary headers in dummy.c:
Index: src/modules/dummy/dummy.c =================================================================== --- src/modules/dummy/dummy.c (revision 89838) +++ src/modules/dummy/dummy.c (working copy) @@ -17,7 +17,10 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ -#include "sysinc.h" +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "module.h" /* the variable keeps timeout setting for item processing */
the module compiles cleanly requiring just module.h from Zabbix SVN or source tarball. Zabbix code compiles too.