mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Update struct initializer to work with relatively older C++.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
+3
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user