Merge pull request #10811 from keszybz/define-main-through-macro
Define main through macro
This commit is contained in:
@@ -506,4 +506,23 @@ static inline int __coverity_check__(int condition) {
|
||||
DEFINE_PUBLIC_TRIVIAL_REF_FUNC(type, name); \
|
||||
DEFINE_PUBLIC_TRIVIAL_UNREF_FUNC(type, name, free_func);
|
||||
|
||||
/* Negative return values from impl are mapped to EXIT_FAILURE, and
|
||||
* everything else means success! */
|
||||
#define DEFINE_MAIN_FUNCTION(impl) \
|
||||
int main(int argc, char *argv[]) { \
|
||||
int r; \
|
||||
r = impl(argc, argv); \
|
||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; \
|
||||
}
|
||||
|
||||
/* Zero is mapped to EXIT_SUCCESS, and both negative and positive values
|
||||
* are mapped to EXIT_FAILURE.
|
||||
* Note: this means "true" maps to EXIT_FAILURE. */
|
||||
#define DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(impl) \
|
||||
int main(int argc, char *argv[]) { \
|
||||
int r; \
|
||||
r = impl(argc, argv); \
|
||||
return r != 0 ? EXIT_FAILURE : EXIT_SUCCESS; \
|
||||
}
|
||||
|
||||
#include "log.h"
|
||||
|
||||
Reference in New Issue
Block a user