On Fri, May 07, 2004 at 02:03:39PM -0400, David Jones wrote:

> 1. Can I put a section directive on a CLASS, intending that all methods
>    in the class end up in the indicated section?  Or do I have to
>    annotate each method separately?

No, each method must have its own section attribute.

> 2. Can I put a section directive on a TEMPLATE class, intending that all
>    classes instantiated from the template will inherit the section
>    directive?

Same as above. You are allowed to put template class methods into
different sections.

> Anyone ever tried this?  Or is C++ under prc-tools generally considered too 
> ambitious?

It works just fine. The only real issue with templates is when you
instantiate a lot of them with different template parameters, because
the section can fill up quite quickly.

It's not very difficult to do. Have a single sections.h file that every
other .h file includes as the first thing, and do

-- sections.h
#define DATA_SECTION __attribute__ ((section ("data")))
#define DATA_SECTION_OFF
#define FORM_SECTION __attribute__ ((section ("forms")))
#define FORM_SECTION_OFF

-- Foo.h
#include "sections.h"

class Foo {
public:
  Foo()                      DATA_SECTION;
  ~Foo()                     DATA_SECTION;
  UInt32 GetValue() const    DATA_SECTION_OFF;
};

I use the *_OFF macros to easily move a method into the main section
(usually for debugging).

Also, inlines and sections don't mix at all. Don't do that.

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

Dave is currently listening to Genuine Live 1966 - 1966-05-16 - Just Like A Woman 
(Genuine Live 1966)

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to