examples/helloxx: add extern "C" to main implementation directly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-11-18 18:21:22 +08:00 committed by Alan Carvalho de Assis
parent 4e9921c9b2
commit 75c11d4480
2 changed files with 22 additions and 27 deletions

View File

@ -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;
}

View File

@ -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;
}