public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: [ECOS] Can I use the dynamic memory allocation on the class o bject? Thanks a lot.
@ 2003-04-29 17:35 Schumacher, Gordon
  2003-04-29 17:57 ` [ECOS] Can I use the dynamic memory allocation on the class object? " QiangHuang
  0 siblings, 1 reply; 4+ messages in thread
From: Schumacher, Gordon @ 2003-04-29 17:35 UTC (permalink / raw)
  To: 'QiangHuang', Ecos-Discuss

Is there something obvious that I'm missing - is there a reason you're not
using the following?

my_class *pclass = new my_class;

If I'm not dreadfully mistaken, that's dynamic allocation...

# -----Original Message-----
# From: QiangHuang [mailto:jameshq@liverpool.ac.uk]
# Sent: Tuesday, April 29, 2003 11:07 AM
# To: Ecos-Discuss
# Subject: [ECOS] Can I use the dynamic memory allocation on the class
# object? Thanks a lot.
# 
# 
# Hi all:
# I would like to use the dynamic memory allocation on the Class object
# creation, but how is its associated class constructor called?
# 
# foe example:
# 
# class my_class
# { 
#    public:
#     int a
#     my_class() { a=100;}
#     ~my_class(){};
# }
# 
# 
# my_class *pclass = malloc(sizeof(my_class));
# 
# // by now has the my_class constructor been called?, or 
# should I call it by myself?
# // I have tried the following: (I guess only the global class 
# object constructor will be called when system started)
# 
# pclass->my_class();	// error
# 
# // or must I set it by
# pclass->a=100;
# 
# thanks a lot.
# 
# 
# -- 
# 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [ECOS] Can I use the dynamic memory allocation on the class object? Thanks a lot.
  2003-04-29 17:35 [ECOS] Can I use the dynamic memory allocation on the class o bject? Thanks a lot Schumacher, Gordon
@ 2003-04-29 17:57 ` QiangHuang
  2003-04-29 18:10   ` Nick Garnett
  0 siblings, 1 reply; 4+ messages in thread
From: QiangHuang @ 2003-04-29 17:57 UTC (permalink / raw)
  To: Schumacher, Gordon; +Cc: Ecos-Discuss

Thank you very much for your help.
Maybe I was not doing in the right way. The problem is I can use new to
create a class object when building the eCOS library. but when linking with
my application I got the following error:

warning: no memory  region specified for section `.eh_frame'
section .eh_frame [00092508 -> 00092d8f] overlaps section .text [00040040 ->
00093287].

but this can be done with malloc() without problem.

Maybe I have missed something. Thanks  a lot.

BTW can I do it by the replacement new as:


cyg_uint8 *pbuf = malloc( sizeof(my_class) );

my_class *pclass = new(pbuf) my_class;?	// will the class constructor be
called here?

Thanks a lot.


-----Original Message-----
From: Schumacher, Gordon [mailto:gordon_schumacher@maxtor.com]
Sent: 29 April 2003 18:15
To: 'QiangHuang'; Ecos-Discuss
Subject: RE: [ECOS] Can I use the dynamic memory allocation on the class
object? Thanks a lot.


Is there something obvious that I'm missing - is there a reason you're not
using the following?

my_class *pclass = new my_class;

If I'm not dreadfully mistaken, that's dynamic allocation...

# -----Original Message-----
# From: QiangHuang [mailto:jameshq@liverpool.ac.uk]
# Sent: Tuesday, April 29, 2003 11:07 AM
# To: Ecos-Discuss
# Subject: [ECOS] Can I use the dynamic memory allocation on the class
# object? Thanks a lot.
#
#
# Hi all:
# I would like to use the dynamic memory allocation on the Class object
# creation, but how is its associated class constructor called?
#
# foe example:
#
# class my_class
#

#    public:
#     int a
#     my_class() { a=100;}
#     ~my_class(){};
# }
#
#
# my_class *pclass = malloc(sizeof(my_class));
#
# // by now has the my_class constructor been called?, or
# should I call it by myself?
# // I have tried the following: (I guess only the global class
# object constructor will be called when system started)
#
# pclass->my_class();	// error
#
# // or must I set it by
# pclass->a=100;
#
# thanks a lot.
#
#
# --
# 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Can I use the dynamic memory allocation on the class object? Thanks a lot.
  2003-04-29 17:57 ` [ECOS] Can I use the dynamic memory allocation on the class object? " QiangHuang
@ 2003-04-29 18:10   ` Nick Garnett
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Garnett @ 2003-04-29 18:10 UTC (permalink / raw)
  To: QiangHuang; +Cc: Schumacher, Gordon, Ecos-Discuss

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

> Thank you very much for your help.
> Maybe I was not doing in the right way. The problem is I can use new to
> create a class object when building the eCOS library. but when linking with
> my application I got the following error:
> 
> warning: no memory  region specified for section `.eh_frame'
> section .eh_frame [00092508 -> 00092d8f] overlaps section .text [00040040 ->
> 00093287].
> 

Which platform are you using? and what version of eCos? I recently
checked in a lot of fixes for exactly this problem. Either you are
using an older version of eCos, or there was a bug in the change for
your platform. Does the infra package cxxsupp.cxx test program build
in your configuration?


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [ECOS] Can I use the dynamic memory allocation on the class o bject? Thanks a lot.
@ 2003-04-29 19:34 Schumacher, Gordon
  0 siblings, 0 replies; 4+ messages in thread
From: Schumacher, Gordon @ 2003-04-29 19:34 UTC (permalink / raw)
  To: 'QiangHuang'; +Cc: Ecos-Discuss

Well, that's certainly one way to do it, using the in-place version of new -
but you shouldn't have to do that.  I'm guessing that Nick Garnett's
solution is the right one...

# -----Original Message-----
# From: QiangHuang [mailto:jameshq@liverpool.ac.uk]
# Sent: Tuesday, April 29, 2003 11:34 AM
# To: Schumacher, Gordon
# Cc: Ecos-Discuss
# Subject: RE: [ECOS] Can I use the dynamic memory allocation 
# on the class
# object? Thanks a lot.
# 
# 
# Thank you very much for your help.
# Maybe I was not doing in the right way. The problem is I can 
# use new to
# create a class object when building the eCOS library. but 
# when linking with
# my application I got the following error:
# 
# warning: no memory  region specified for section `.eh_frame'
# section .eh_frame [00092508 -> 00092d8f] overlaps section 
# .text [00040040 ->
# 00093287].
# 
# but this can be done with malloc() without problem.
# 
# Maybe I have missed something. Thanks  a lot.
# 
# BTW can I do it by the replacement new as:
# 
# 
# cyg_uint8 *pbuf = malloc( sizeof(my_class) );
# 
# my_class *pclass = new(pbuf) my_class;?	// will the 
# class constructor be
# called here?
# 
# Thanks a lot.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-04-29 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-29 17:35 [ECOS] Can I use the dynamic memory allocation on the class o bject? Thanks a lot Schumacher, Gordon
2003-04-29 17:57 ` [ECOS] Can I use the dynamic memory allocation on the class object? " QiangHuang
2003-04-29 18:10   ` Nick Garnett
2003-04-29 19:34 [ECOS] Can I use the dynamic memory allocation on the class o bject? " Schumacher, Gordon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).