This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Question about "new" operator in C++ and "malloc()" function in C. Thanks a lot


Thanks a lot Nick and Jifl for your reply.

Q1
as eCOS built with "libtarget.a libgcc.a libsupc++.a".   Does the ISO C
package (in eCOS source) implement all the ISO standard C support? Does
anyother supporting functions  comes from libgcc.a rather than the ISO C
package? (would this cause any conflict between ISO C package and libgcc.a
if both supply the function (same name)?) (I am new to the GNU compiler
library, so please correct me if I am wrong. thanks)

Q2
As ISO C support is implemented as a package suppiled with eCOS in source
form, does "new/delete" opeartor also implemented and suppiled with eCOS in
source form? or come directly from the libsupc++.a library or as built-in
with C++ compiler?

Thanks a lot.

Best regards.

qiang

-----Original Message-----
From: ecos-discuss-owner@sources.redhat.com
[mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Nick Garnett
Sent: 30 July 2003 11:44
To: QiangHuang
Cc: 'Ecos-Discuss'
Subject: Re: [ECOS] Question about "new" operator in C++ and "malloc()"
function in C. Thanks a lot


"QiangHuang" <jameshq@liverpool.ac.uk> writes:

> 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?)? )

If new is being used to allocate memory, then it needs exactly the
same support as malloc(). It just calls malloc() to do the
allocation. However, in some places in eCos we use a "placement new"
where the memory to be used is passed in as an argument to new. This
is done mainly so that constructors can get called correctly, there is
no need for extra support.

>
> 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?)?

We currently don't support any of the C++ runtime library routines. To
do this properly would also need a reorganization of the C library to
abstract out common code and preserve the expected relationships
between functions. Only functions/operators that are defined as part
of the language (like new and delete) are currently supported.

--
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com      The eCos and RedBoot experts


--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]