mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-23 07:13:44 +02:00
Only use extern
in embedtool.cpp if language is C++
In C, variables defined as `const` have external linkage. In C++, variables defined as `const` have internal linkage, and we need to define them as `extern const` for them to have external linkage like in C. However, in C, defining a variable as `extern const` throws a compiler error, so we need to add `extern` only for C++ files.
This commit is contained in:
parent
54d915860f
commit
215046d8b4
1 changed files with 2 additions and 2 deletions
|
@ -41,7 +41,7 @@ int main(int argc, char **argv) {
|
|||
return 3;
|
||||
}
|
||||
|
||||
outputf << "#include <stddef.h>\n#include <stdint.h>\nextern const uint8_t " << arrayname << "[] = {";
|
||||
outputf << "#ifndef MKXPZ_EMBEDTOOL_" << arrayname << "\n#define MKXPZ_EMBEDTOOL_" << arrayname << "\n#include <stddef.h>\n#include <stdint.h>\n#ifdef __cplusplus\nextern\n#endif /* __cplusplus */\nconst uint8_t " << arrayname << "[] = {";
|
||||
|
||||
uint64_t len = 0;
|
||||
for (;;) {
|
||||
|
@ -53,7 +53,7 @@ int main(int argc, char **argv) {
|
|||
++len;
|
||||
}
|
||||
|
||||
outputf << "};\nextern const size_t " << arrayname << "_len = " << len << "ULL;";
|
||||
outputf << "};\n#ifdef __cplusplus\nextern\n#endif /* __cplusplus */\nconst size_t " << arrayname << "_len = " << len << "ULL;\n#endif /* MKXPZ_EMBEDTOOL_" << arrayname << " */\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue