From 75c11d448027a57f7e7e28fb8828e8fa932377cb Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 18 Nov 2021 18:21:22 +0800 Subject: [PATCH] examples/helloxx: add extern "C" to main implementation directly Signed-off-by: Xiang Xiao --- examples/helloxx/helloxx_main.cxx | 32 +++++++++++++++---------------- testing/cxxtest/cxxtest_main.cxx | 17 +++++++--------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/examples/helloxx/helloxx_main.cxx b/examples/helloxx/helloxx_main.cxx index 8ed802a25..c9553ad75 100644 --- a/examples/helloxx/helloxx_main.cxx +++ b/examples/helloxx/helloxx_main.cxx @@ -101,31 +101,29 @@ static CHelloWorld g_HelloWorld; * Name: helloxx_main ****************************************************************************/ -extern "C" + +extern "C" int main(int argc, FAR char *argv[]) { - int main(int argc, FAR char *argv[]) - { - // Exercise an explicitly instantiated C++ object + // Exercise an explicitly instantiated C++ object - CHelloWorld *pHelloWorld = new CHelloWorld; - printf("helloxx_main: Saying hello from the dynamically constructed instance\n"); - pHelloWorld->HelloWorld(); + CHelloWorld *pHelloWorld = new CHelloWorld; + printf("helloxx_main: Saying hello from the dynamically constructed instance\n"); + pHelloWorld->HelloWorld(); - // Exercise an C++ object instantiated on the stack + // Exercise an C++ object instantiated on the stack - CHelloWorld HelloWorld; + CHelloWorld HelloWorld; - printf("helloxx_main: Saying hello from the instance constructed on the stack\n"); - HelloWorld.HelloWorld(); + printf("helloxx_main: Saying hello from the instance constructed on the stack\n"); + HelloWorld.HelloWorld(); - // Exercise an statically constructed C++ object + // Exercise an statically constructed C++ object #ifdef CONFIG_HAVE_CXXINITIALIZE - printf("helloxx_main: Saying hello from the statically constructed instance\n"); - g_HelloWorld.HelloWorld(); + printf("helloxx_main: Saying hello from the statically constructed instance\n"); + g_HelloWorld.HelloWorld(); #endif - delete pHelloWorld; - return 0; - } + delete pHelloWorld; + return 0; } diff --git a/testing/cxxtest/cxxtest_main.cxx b/testing/cxxtest/cxxtest_main.cxx index 0e03a8604..06cfc86c9 100644 --- a/testing/cxxtest/cxxtest_main.cxx +++ b/testing/cxxtest/cxxtest_main.cxx @@ -214,18 +214,15 @@ static void test_exception(void) // Name: cxxtest_main //***************************************************************************/ -extern "C" +extern "C" int main(int argc, char *argv[]) { - int main(int argc, char *argv[]) - { - test_ofstream(); - test_iostream(); - test_stl(); - test_rtti(); + test_ofstream(); + test_iostream(); + test_stl(); + test_rtti(); #ifdef CONFIG_CXX_EXCEPTION - test_exception(); + test_exception(); #endif - return 0; - } + return 0; }