Disallow variable-length arrays and turn on -Wpedantic in Clang and GCC.

PiperOrigin-RevId: 562832747
Change-Id: I0532624cee31e089a47426305d885687eb0fc5c5
This commit is contained in:
Saran Tunyasuvunakool
2023-09-05 11:04:12 -07:00
committed by Copybara-Service
parent 8ffdee355a
commit 329ed193ac
17 changed files with 121 additions and 99 deletions
+9 -1
View File
@@ -23,7 +23,7 @@
namespace mujoco {
namespace {
constexpr int kBufferSize = 1000;
constexpr int kBufferSize = 1024;
char* ErrorMessageBuffer() {
static char error_message[kBufferSize] = "";
@@ -132,5 +132,13 @@ TEST_F(MujocoErrorAndWarningTest, MjuWarningS) {
EXPECT_EQ(std::string(WarningMessageBuffer()), expected_message);
}
TEST_F(MujocoErrorAndWarningTest, MjuErrorInternal) {
ClearErrorMessage();
mjERROR("foobar %d", 123);
std::string funcname(__func__);
ASSERT_TRUE(funcname.length());
EXPECT_EQ(std::string(ErrorMessageBuffer()), funcname + ": foobar 123");
}
} // namespace
} // namespace mujoco