apps/examples/helloxx entry point name was mangled when built as an NSH builtin; plus some README updates

This commit is contained in:
Gregory Nutt 2013-05-16 09:36:55 -06:00
parent 44fe713165
commit 8445a4cdcd
5 changed files with 26 additions and 25 deletions

View File

@ -553,3 +553,5 @@
is not selected. Also, complete the empty Kconfig file (2013-5-7). is not selected. Also, complete the empty Kconfig file (2013-5-7).
* apps/NxWidgets/Kconfig: Updated to match NxWidgets/Kconfig by * apps/NxWidgets/Kconfig: Updated to match NxWidgets/Kconfig by
Ken Pettit (2013-5-11). Ken Pettit (2013-5-11).
* apps/examples/helloxx: C++ name mangling was occurring when this
example is built as an NSH built-in application. (2013-5-16).

View File

@ -59,13 +59,10 @@ CNTXTDIRS = pwm
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover flash_test ftpd CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover flash_test ftpd
CNTXTDIRS += hello json keypadtestmodbus mtdpart nettest nxlines relays CNTXTDIRS += hello helloxx json keypadtestmodbus mtdpart nettest nxlines relays
CNTXTDIRS += qencoder smart_test telnetd watchdog wgetjson CNTXTDIRS += qencoder smart_test telnetd watchdog wgetjson
endif endif
ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y)
CNTXTDIRS += helloxx
endif
ifeq ($(CONFIG_EXAMPLES_LCDRW_BUILTIN),y) ifeq ($(CONFIG_EXAMPLES_LCDRW_BUILTIN),y)
CNTXTDIRS += lcdrw CNTXTDIRS += lcdrw
endif endif

View File

@ -100,7 +100,7 @@ $(CXXOBJS): %$(OBJEXT): %.cxx
$(call ARCHIVE, $(BIN), $(OBJS)) $(call ARCHIVE, $(BIN), $(OBJS))
@touch .built @touch .built
ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)

View File

@ -100,7 +100,7 @@ $(CXXOBJS): %$(OBJEXT): %.cxx
$(call ARCHIVE, $(BIN), $(OBJS)) $(call ARCHIVE, $(BIN), $(OBJS))
@touch .built @touch .built
ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)

View File

@ -1,7 +1,7 @@
//*************************************************************************** //***************************************************************************
// examples/helloxx/helloxx_main.cxx // examples/helloxx/helloxx_main.cxx
// //
// Copyright (C) 2009, 2011-2012 Gregory Nutt. All rights reserved. // Copyright (C) 2009, 2011-2013 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org> // Author: Gregory Nutt <gnutt@nuttx.org>
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
@ -128,38 +128,40 @@ static CHelloWorld g_HelloWorld;
* Name: helloxx_main * Name: helloxx_main
****************************************************************************/ ****************************************************************************/
int helloxx_main(int argc, char *argv[]) extern "C"
{ {
// If C++ initialization for static constructors is supported, then do int helloxx_main(int argc, char *argv[])
// that first {
// If C++ initialization for static constructors is supported, then do
// that first
#ifdef CONFIG_HAVE_CXXINITIALIZE #ifdef CONFIG_HAVE_CXXINITIALIZE
up_cxxinitialize(); up_cxxinitialize();
#endif #endif
// Exercise an explictly instantiated C++ object // Exercise an explictly instantiated C++ object
CHelloWorld *pHelloWorld = new CHelloWorld; CHelloWorld *pHelloWorld = new CHelloWorld;
printf("helloxx_main: Saying hello from the dynamically constructed instance\n"); printf("helloxx_main: Saying hello from the dynamically constructed instance\n");
pHelloWorld->HelloWorld(); pHelloWorld->HelloWorld();
// Exercise an C++ object instantiated on the stack // Exercise an C++ object instantiated on the stack
#ifndef CONFIG_EXAMPLES_HELLOXX_NOSTACKCONST #ifndef CONFIG_EXAMPLES_HELLOXX_NOSTACKCONST
CHelloWorld HelloWorld; CHelloWorld HelloWorld;
printf("helloxx_main: Saying hello from the instance constructed on the stack\n"); printf("helloxx_main: Saying hello from the instance constructed on the stack\n");
HelloWorld.HelloWorld(); HelloWorld.HelloWorld();
#endif #endif
// Exercise an statically constructed C++ object // Exercise an statically constructed C++ object
#ifdef CONFIG_HAVE_CXXINITIALIZE #ifdef CONFIG_HAVE_CXXINITIALIZE
printf("helloxx_main: Saying hello from the statically constructed instance\n"); printf("helloxx_main: Saying hello from the statically constructed instance\n");
g_HelloWorld.HelloWorld(); g_HelloWorld.HelloWorld();
#endif #endif
delete pHelloWorld; delete pHelloWorld;
return 0; return 0;
}
} }