diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 491b1ba9f..c75b479b2 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -231,7 +231,8 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri writeError(filename, lineno, _errorLogger, "syntaxError", errmsg.str()); } - if (str.compare(i, 6, "#error") == 0 || str.compare(i, 8, "#warning") == 0) + if ((str.compare(i, 6, "#error") == 0 && (!_settings || _settings->userDefines.empty())) || + str.compare(i, 8, "#warning") == 0) { if (str.compare(i, 6, "#error") == 0) code << "#error";