From 303e81e33e630632dc2996f472a07f10cd42a55a Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Thu, 8 Aug 2024 08:39:58 +0100 Subject: [PATCH] Fix the static keyword being missing in the output for global variables --- CHANGELOG.md | 1 + src/ccc/print_cpp.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3eaa6c..d578d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## v2.1 - Variable symbols are no longer incorrectly deduplicated as if they were types. +- The static keyword is no longer missing from the output for static global variables. - Structs defined inside global variable definitions are now printed with the correct C++ syntax. - Fixed an issue where null addresses would be handled incorrectly. - stdump: Added `--sort-by-address` option. diff --git a/src/ccc/print_cpp.cpp b/src/ccc/print_cpp.cpp index d354fa2..96d389c 100644 --- a/src/ccc/print_cpp.cpp +++ b/src/ccc/print_cpp.cpp @@ -326,7 +326,9 @@ void CppPrinter::global_variable( global_storage_comment(symbol.storage, symbol.address()); - if(m_config.make_globals_extern) { + if(symbol.storage_class != STORAGE_CLASS_NONE) { + print_cpp_storage_class(out, symbol.storage_class); + } else if(m_config.make_globals_extern) { print_cpp_storage_class(out, STORAGE_CLASS_EXTERN); }