Skip to content

Commit

Permalink
[C++] Null terminate constant char arrays to avoid warnings. Issue #832.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Dec 31, 2020
1 parent 5dacc79 commit 15b23b8
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ private void generateConstPropertyMethods(
new Formatter(sb).format("\n" +
indent + " SBE_NODISCARD const char *%1$s() const\n" +
indent + " {\n" +
indent + " static const std::uint8_t %1$sValues[] = { %2$s };\n\n" +
indent + " static const std::uint8_t %1$sValues[] = { %2$s, 0 };\n\n" +

indent + " return (const char *)%1$sValues;\n" +
indent + " }\n",
Expand All @@ -1727,7 +1727,7 @@ private void generateConstPropertyMethods(
sb.append(String.format("\n" +
indent + " SBE_NODISCARD %1$s %2$s(const std::uint64_t index) const\n" +
indent + " {\n" +
indent + " static const std::uint8_t %2$sValues[] = { %3$s };\n\n" +
indent + " static const std::uint8_t %2$sValues[] = { %3$s, 0 };\n\n" +

indent + " return (char)%2$sValues[index];\n" +
indent + " }\n",
Expand Down

0 comments on commit 15b23b8

Please sign in to comment.