public inbox for
 help / color / mirror / Atom feed
From: Todd Hoff <>
Cc: C++ Embedded <>
Subject: Re: static function tables
Date: Mon, 29 Jun 1998 19:55:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Ken wrote:

> The catch in this case is that the objects are static, and this is a
> memory-limited embedded system where I don't want to copy a const array
> of structures in ROM into equivalent C++ structures in RAM. This is kind
> of a general problem in using C++ in a memory-limited environment. 

I would be inclined to overload the new operator and take the memory
out of a static array or some other fixed source. Best of both worlds.
In fact, in a memory constrained system i would overload the global
new and allocate memory from pools of fixed sized buffers. Works
best i think.

> are cases where it would be nice to initialize static const C++ objects
> at compile or link time (on the host) rather than just before main() (on
> the target).

Some say potatoes...

> I've seen a trick lately (I think in Embedded Systems Programming) where
> one exposes a C++ class that defines an internal private struct for the
> static const data. Something like
>  class public_class
>  {
>  private:
>      struct static_data { ... };
>      static const static_data data[]; // stored in ROM
>  };
> This looks applicable to the situation.

This is the pimple pattern or the handle pattern. Works fine.
Just better make sure your rom address is correct!

   Desperate measures require the invention of desperate times. 
      -- Todd Hoff

      reply	other threads:[~1998-06-29 19:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-27  1:34 Ken
1998-06-27  8:40 ` Todd Hoff
1998-06-29 17:27   ` Ken
1998-06-29 19:55     ` Todd Hoff [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).