You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/11/23 20:23:17 UTC

[incubator-nuttx-apps] branch master updated: examples/helloxx: add extern "C" to main implementation directly

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 75c11d4  examples/helloxx: add extern "C" to main implementation directly
75c11d4 is described below

commit 75c11d448027a57f7e7e28fb8828e8fa932377cb
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Nov 18 18:21:22 2021 +0800

    examples/helloxx: add extern "C" to main implementation directly
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 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 8ed802a..c9553ad 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 0e03a86..06cfc86 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;
 }