Skip to content

Commit

Permalink
Add constant export declaration for MRBC output compiled as C++
Browse files Browse the repository at this point in the history
Otherwise, C++ compilers will skip this constant when producing object files.
  • Loading branch information
dabroz authored and matz committed Nov 24, 2016
1 parent 1af9e36 commit 401ad45
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/dump.c
Expand Up @@ -1059,13 +1059,15 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
return MRB_DUMP_WRITE_FAULT; return MRB_DUMP_WRITE_FAULT;
} }
if (fprintf(fp, if (fprintf(fp,
"extern const uint8_t %s[];\n"
"const uint8_t\n" "const uint8_t\n"
"#if defined __GNUC__\n" "#if defined __GNUC__\n"
"__attribute__((aligned(%u)))\n" "__attribute__((aligned(%u)))\n"
"#elif defined _MSC_VER\n" "#elif defined _MSC_VER\n"
"__declspec(align(%u))\n" "__declspec(align(%u))\n"
"#endif\n" "#endif\n"
"%s[] = {", "%s[] = {",
initname,
(uint16_t)MRB_DUMP_ALIGNMENT, (uint16_t)MRB_DUMP_ALIGNMENT, initname) < 0) { (uint16_t)MRB_DUMP_ALIGNMENT, (uint16_t)MRB_DUMP_ALIGNMENT, initname) < 0) {
mrb_free(mrb, bin); mrb_free(mrb, bin);
return MRB_DUMP_WRITE_FAULT; return MRB_DUMP_WRITE_FAULT;
Expand Down

0 comments on commit 401ad45

Please sign in to comment.