Update `struct` initializer to work with relatively older `C++`.
MODIFY
build_config/ci/gcc-clang.rb
build_config/ci/gcc-clang.rb
@@ -28,7 +28,7 @@ MRuby::Build.new('cxx_abi') do |conf|
conf.toolchain
conf.gembox 'full-core'
- conf.cc.flags += %w(-fpermissive)
+ conf.cc.flags += %w(-fpermissive -std=gnu++03)
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA MRB_UTF8_STRING)
end

MODIFY
mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
@@ -141,7 +141,8 @@ static listcmd_parser_state*
listcmd_parser_state_new(mrb_state *mrb)
{
listcmd_parser_state *st = (listcmd_parser_state*)mrb_malloc(mrb, sizeof(listcmd_parser_state));
- *st = (listcmd_parser_state){0};
+ static const listcmd_parser_state st_zero = {0};
+ *st = st_zero;
return st;
}

MODIFY
mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
@@ -186,9 +186,9 @@ static mrb_debug_context*
mrb_debug_context_new(mrb_state *mrb)
{
mrb_debug_context *dbg = (mrb_debug_context*)mrb_malloc(mrb, sizeof(mrb_debug_context));
+ static const mrb_debug_context dbg_zero = {0};
- *dbg = (mrb_debug_context){0};
-
+ *dbg = dbg_zero;
dbg->xm = DBG_INIT;
dbg->xphase = DBG_PHASE_BEFORE_RUN;
dbg->next_bpno = 1;
@@ -225,9 +225,9 @@ static mrdb_state*
mrdb_state_new(mrb_state *mrb)
{
mrdb_state *mrdb = (mrdb_state*)mrb_malloc(mrb, sizeof(mrdb_state));
+ static const mrdb_state mrdb_zero = {0};
- *mrdb = (mrdb_state){0};
-
+ *mrdb = mrdb_zero;
mrdb->dbg = mrb_debug_context_get(mrb);
mrdb->command = (char*)mrb_malloc(mrb, MAX_COMMAND_LINE+1);
mrdb->print_no = 1;

MODIFY
mrbgems/mruby-socket/src/socket.c
mrbgems/mruby-socket/src/socket.c
@@ -66,8 +66,8 @@ static const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
{
if (af == AF_INET)
{
- struct sockaddr_in in;
- in = (struct sockaddr_in){0};
+ struct sockaddr_in in = {0};
+
in.sin_family = AF_INET;
memcpy(&in.sin_addr, src, sizeof(struct in_addr));
getnameinfo((struct sockaddr *)&in, sizeof(struct
@@ -76,8 +76,8 @@ static const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
}
else if (af == AF_INET6)
{
- struct sockaddr_in6 in;
- in = (struct sockaddr_in6){0};
+ struct sockaddr_in6 in = {0};
+
in.sin6_family = AF_INET6;
memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
getnameinfo((struct sockaddr *)&in, sizeof(struct
@@ -89,9 +89,9 @@ static const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
static int inet_pton(int af, const char *src, void *dst)
{
- struct addrinfo hints, *res, *ressave;
+ struct addrinfo hints = {0};
+ struct addrinfo *res, *ressave;
- hints = (struct addrinfo){0};
hints.ai_family = af;
if (getaddrinfo(src, NULL, &hints, &res) != 0)
@@ -117,7 +117,7 @@ static int inet_pton(int af, const char *src, void *dst)
static mrb_value
mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
{
- struct addrinfo hints, *res0, *res;
+ struct addrinfo hints = {0}, *res0, *res;
mrb_value ai, ary, family, lastai, nodename, protocol, sa, service, socktype;
mrb_int flags;
int arena_idx, error;
@@ -148,7 +148,6 @@ mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
mrb_raise(mrb, E_TYPE_ERROR, "service must be String, Integer, or nil");
}
- hints = (struct addrinfo){0};
hints.ai_flags = (int)flags;
if (mrb_integer_p(family)) {

MODIFY
src/class.c
src/class.c
@@ -1698,8 +1698,10 @@ mrb_define_module_function(mrb_state *mrb, struct RClass *c, const char *name, m
static void
mc_clear(mrb_state *mrb)
{
+ static const struct mrb_cache_entry ce_zero ={0};
+
for (int i=0; i<MRB_METHOD_CACHE_SIZE; i++) {
- mrb->cache[i] = (struct mrb_cache_entry){0};
+ mrb->cache[i] = ce_zero;
}
}

Update `struct` initializer to work with relatively older `C++`.