From 704a5f3dde6a006418cbf01a3b9a67e6957f1164 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Fri, 16 Aug 2024 21:18:44 +0000 Subject: [PATCH] pw_spi_linux: Remove linkage specification from cli main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the C++ standard, the main function shall not be declared with a linkage-specification. An upcoming Crosstool release includes [20-1706 [Clang] Strengthen checks for `main` to meet `[basic.start.main]p3`’s requirements (#101853)](http://go/compilers/37ec6e5f12afe4a37872bf28f280423696f39019), which will lead to breakages when compiling `extern "C" int main...`. This CL removes the linkage specification from pw_spi_linux_cli's main function and moves the main function to the global namespace. Change-Id: I59c6a4eebc638b93cde5c22fa439885747ff90c4 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230291 Lint: Lint 🤖 Reviewed-by: Armando Montanez Commit-Queue: Auto-Submit Pigweed-Auto-Submit: Taylor Cramer Presubmit-Verified: CQ Bot Account --- pw_spi_linux/cli.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pw_spi_linux/cli.cc b/pw_spi_linux/cli.cc index 9ca69cd029..959ed3f409 100644 --- a/pw_spi_linux/cli.cc +++ b/pw_spi_linux/cli.cc @@ -277,7 +277,7 @@ void WriteOutput(const std::string& path, } } -PW_EXTERN_C int main(int argc, char* argv[]) { +int MainInNamespace(int argc, char* argv[]) { auto maybe_args = ParseArgs(argc, argv); if (!maybe_args.ok()) { return 1; @@ -326,3 +326,7 @@ PW_EXTERN_C int main(int argc, char* argv[]) { } // namespace } // namespace pw::spi + +int main(int argc, char* argv[]) { + return pw::spi::MainInNamespace(argc, argv); +}