[ECOS] Question about "new" operator in C++ and "malloc()" function in C. Thanks a lot
Jonathan Larmour
jifl@eCosCentric.com
Wed Jul 30 10:09:00 GMT 2003
QiangHuang wrote:
> Dear all:
> I have this question in mind for a while and I still can't figure it
> out. Hope somebody can share me some idea on this question. Thanks a lot.
>
> Question 1:
> When using "new" operator in C++ for building eCOS application, no
> supporting package is needed while for using "malloc()" function, supporting
> package "memalloc" has to be added for building the eCOS library. Those two
> are all for memory allocation, so I wonder why "new" doesn't need any other
> supporting package while "malloc" does. (Can I guess the reason that: "new"
> is a operator, which has been implemented by the C++ compiler while for
> "malloc()" is a function, which will need lower level(system related)
> function support (from some other library, stdlib?)? )
new uses malloc. If you use a new (other than a placement new - google for
what that is if you don't know) then that will have a dependency on malloc
and linking will fail if malloc isn't there.
> Question 2:
> When compiling/linking a 'C' eCOS application "-nostdlib" need to be
> suppiled, but if for 'C++' eCOS appliation do I need to supply any other
> directive? Or "-nostdlib" is applied for both 'C' and "C++" built eCOS
> appliation (Does this means we can just use C/C++ built in operator for
> building eCOS appliation not any other supporting functions?)?
RTFM :-). Use -nostdlib for both. The eCos linker script pulls in any
standard libraries required instead.
Jifl
--
eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[ can rejoice because thorns have roses." -Lincoln ]-- Opinions==mine
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
More information about the Ecos-discuss
mailing list