Просмотр исходного кода

Avoid -Wstring-plus-int warning

In `cmState::GetGlobalProperty` we use a macro to produce a string of
the form ";a;b;c" and want to return "a;b;c" by skipping the leading
";".  Switch from pointer arithmetic to indexing+addressing to silence
the "warning: adding 'int' to a string does not append to the string"
diagnostic from Clang.
Brad King 7 лет назад
Родитель
Сommit
68eabb3576
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      Source/cmState.cxx

+ 2 - 2
Source/cmState.cxx

@@ -545,10 +545,10 @@ const char* cmState::GetGlobalProperty(const std::string& prop)
   }
 #define STRING_LIST_ELEMENT(F) ";" #F
   if (prop == "CMAKE_C_KNOWN_FEATURES") {
-    return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
+    return &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1];
   }
   if (prop == "CMAKE_CXX_KNOWN_FEATURES") {
-    return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
+    return &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1];
   }
 #undef STRING_LIST_ELEMENT
   return this->GlobalProperties.GetPropertyValue(prop);