From 5a576028607c4bd7b46e8b1d2726329355d4bc03 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sat, 21 Aug 2021 15:42:57 +0900 Subject: Organize the include of header files - `#include ` is done in `mruby.h`. Eliminate the need to worry about the `MRB_NO_FLOAT` macro. - Include mruby header files before standard header files. If the standard header file is already placed before `mruby.h`, the standard header file added in the future tends to be placed before `mruby.h`. This change should some reduce the chances of macros that must be defined becoming undefined in C++ or including problematic header files in a particular mruby build configuration. --- include/mruby.h | 1 + mrbgems/mruby-cmath/src/cmath.c | 1 - mrbgems/mruby-compiler/core/codegen.c | 5 ++--- mrbgems/mruby-complex/src/complex.c | 1 - mrbgems/mruby-math/src/math.c | 1 - mrbgems/mruby-numeric-ext/src/numeric_ext.c | 1 - mrbgems/mruby-range-ext/src/range.c | 1 - mrbgems/mruby-rational/src/rational.c | 1 - mrbgems/mruby-sprintf/src/sprintf.c | 5 +---- mrbgems/mruby-time/src/time.c | 4 ---- src/dump.c | 4 ++-- src/load.c | 4 ++-- src/numeric.c | 6 +----- src/string.c | 3 --- src/vm.c | 3 --- 15 files changed, 9 insertions(+), 32 deletions(-) diff --git a/include/mruby.h b/include/mruby.h index 2a6bc7753..1cee5b7a6 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -99,6 +99,7 @@ #include #ifndef MRB_NO_FLOAT +#include #include #ifndef FLT_EPSILON #define FLT_EPSILON (1.19209290e-07f) diff --git a/mrbgems/mruby-cmath/src/cmath.c b/mrbgems/mruby-cmath/src/cmath.c index 03b181840..8b0c4d04a 100644 --- a/mrbgems/mruby-cmath/src/cmath.c +++ b/mrbgems/mruby-cmath/src/cmath.c @@ -15,7 +15,6 @@ # error CMath conflicts with 'MRB_NO_FLOAT' configuration #endif -#include #include mrb_value mrb_complex_new(mrb_state *mrb, mrb_float real, mrb_float imag); diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 3f849b0f1..4546e6cc0 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -4,9 +4,6 @@ ** See Copyright Notice in mruby.h */ -#include -#include -#include #include #include #include @@ -19,6 +16,8 @@ #include #include #include +#include +#include #ifndef MRB_CODEGEN_LEVEL_MAX #define MRB_CODEGEN_LEVEL_MAX 1024 diff --git a/mrbgems/mruby-complex/src/complex.c b/mrbgems/mruby-complex/src/complex.c index 286e7e38e..66176c3c1 100644 --- a/mrbgems/mruby-complex/src/complex.c +++ b/mrbgems/mruby-complex/src/complex.c @@ -2,7 +2,6 @@ #include #include #include -#include #ifdef MRB_NO_FLOAT # error Complex conflicts with 'MRB_NO_FLOAT' configuration diff --git a/mrbgems/mruby-math/src/math.c b/mrbgems/mruby-math/src/math.c index 8eccc03e5..79fdb7c6f 100644 --- a/mrbgems/mruby-math/src/math.c +++ b/mrbgems/mruby-math/src/math.c @@ -12,7 +12,6 @@ #include #include -#include static void domain_error(mrb_state *mrb, const char *func) diff --git a/mrbgems/mruby-numeric-ext/src/numeric_ext.c b/mrbgems/mruby-numeric-ext/src/numeric_ext.c index 38d297374..2f2a6c755 100644 --- a/mrbgems/mruby-numeric-ext/src/numeric_ext.c +++ b/mrbgems/mruby-numeric-ext/src/numeric_ext.c @@ -1,7 +1,6 @@ #include #include #include -#include /* * call-seq: diff --git a/mrbgems/mruby-range-ext/src/range.c b/mrbgems/mruby-range-ext/src/range.c index 2d021f31f..633c97b73 100644 --- a/mrbgems/mruby-range-ext/src/range.c +++ b/mrbgems/mruby-range-ext/src/range.c @@ -1,6 +1,5 @@ #include #include -#include static mrb_bool r_le(mrb_state *mrb, mrb_value a, mrb_value b) diff --git a/mrbgems/mruby-rational/src/rational.c b/mrbgems/mruby-rational/src/rational.c index 7d099b1e2..dacce53eb 100644 --- a/mrbgems/mruby-rational/src/rational.c +++ b/mrbgems/mruby-rational/src/rational.c @@ -155,7 +155,6 @@ rational_new_i(mrb_state *mrb, mrb_int n, mrb_int d) } #ifndef MRB_NO_FLOAT -#include #if defined(MRB_INT32) || defined(MRB_USE_FLOAT32) #define frexp_rat(x,exp) frexpf((float)x, exp) diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c index 362d24651..ba5ba4cda 100644 --- a/mrbgems/mruby-sprintf/src/sprintf.c +++ b/mrbgems/mruby-sprintf/src/sprintf.c @@ -5,14 +5,11 @@ */ #include -#include #include #include #include #include -#ifndef MRB_NO_FLOAT -#include -#endif +#include #include #define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */ diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c index 99dcb2bcf..6b9762acf 100644 --- a/mrbgems/mruby-time/src/time.c +++ b/mrbgems/mruby-time/src/time.c @@ -4,10 +4,6 @@ ** See Copyright Notice in mruby.h */ -#ifndef MRB_NO_FLOAT -#include -#endif - #include #include #include diff --git a/src/dump.c b/src/dump.c index 94d5cf74d..4327cb375 100644 --- a/src/dump.c +++ b/src/dump.c @@ -4,12 +4,12 @@ ** See Copyright Notice in mruby.h */ -#include -#include +#include #include #include #include #include +#include #ifndef MRB_NO_FLOAT #include diff --git a/src/load.c b/src/load.c index 83e06f1f8..b5b069fcf 100644 --- a/src/load.c +++ b/src/load.c @@ -4,8 +4,7 @@ ** See Copyright Notice in mruby.h */ -#include -#include +#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include #if SIZE_MAX < UINT32_MAX # error size_t must be at least 32 bits wide diff --git a/src/numeric.c b/src/numeric.c index 5fbf9c586..c159c717a 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -4,17 +4,13 @@ ** See Copyright Notice in mruby.h */ -#ifndef MRB_NO_FLOAT -#include -#endif -#include - #include #include #include #include #include #include +#include #ifndef MRB_NO_FLOAT #ifdef MRB_USE_FLOAT32 diff --git a/src/string.c b/src/string.c index 97e115a19..30d1bcab3 100644 --- a/src/string.c +++ b/src/string.c @@ -15,9 +15,6 @@ #include #include #include -#ifndef MRB_NO_FLOAT -#include -#endif #include typedef struct mrb_shared_string { diff --git a/src/vm.c b/src/vm.c index 57531797c..50ad3b31d 100644 --- a/src/vm.c +++ b/src/vm.c @@ -20,9 +20,6 @@ #include #include #include -#ifndef MRB_NO_FLOAT -#include -#endif #ifdef MRB_NO_STDIO #if defined(__cplusplus) -- cgit v1.2.3