Skip to content

Commit

Permalink
Fix ThrowTheSwitch#147: Push and Pop pragmas not supported by older GCC
Browse files Browse the repository at this point in the history
Solution: check GCC compiler version to be at least 4.6 before enabling
pragma diagnostic push/pop
  • Loading branch information
SteinHeselmans committed Sep 14, 2017
1 parent 6e03886 commit ca05fe4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/cmock_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def create_mock_header_header(file, filename)
file << "\n"
file << "/* Ignore the following warnings, since we are copying code */\n"
file << "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n"
file << "#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))\n"
file << "#pragma GCC diagnostic push\n"
file << "#endif\n"
file << "#if !defined(__clang__)\n"
file << "#pragma GCC diagnostic ignored \"-Wpragmas\"\n"
file << "#endif\n"
Expand All @@ -128,8 +130,10 @@ def create_mock_header_service_call_declarations(file)
def create_mock_header_footer(header)
header << "\n"
header << "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n"
header << "#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))\n"
header << "#pragma GCC diagnostic pop\n"
header << "#endif\n"
header << "#endif\n"
header << "\n"
header << "#endif\n"
end
Expand Down

0 comments on commit ca05fe4

Please sign in to comment.