From ea3c789f646a07ebb4120ebe8c969843fdbb5850 Mon Sep 17 00:00:00 2001 From: Kp Date: Wed, 14 Jan 2015 02:26:20 +0000 Subject: [PATCH] Fix Windows build break due to strchr losing const Mingw32 headers and Apple libc++ both strip const from strchr. Store the result into a const char* to restore const to the pointer. --- similar/main/mission.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/similar/main/mission.cpp b/similar/main/mission.cpp index 6962ef34d..56b5b5c58 100644 --- a/similar/main/mission.cpp +++ b/similar/main/mission.cpp @@ -924,7 +924,11 @@ static int load_mission(const mle *mission) break; const auto &line = buf.line(); const auto lb = line.begin(); - const auto t = strchr(lb, ','); + /* No auto: returned value must be type const char* + * Modern glibc maintains const-ness of the input. + * Apple libc++ and mingw32 do not. + */ + const char *const t = strchr(lb, ','); if (!t) break; auto a = [](char c) {