Hello everybody,

I have a strange problem with writing multi section C++ code using the
prc-tools 2.0. I have written the following class:

#include "HostFile.h" // This is an interface to the HostControl API

#define STRING_SECTION __attribute__ ((section ("String")))
...
class String {
private:
    MemHandle valueHandle;
 ...
public:
...
 String(char *) STRING_SECTION;
 char *getValue() STRING_SECTION;  // Locks valueHandle and returns
chunk
 void ungetValue() STRING_SECTION; // Unlocks chunk
  friend HostFile& operator <<(HostFile&, const String&) STRING_SECTION;

};

The friend function looks like this:

HostFile& operator <<(HostFile& h, const String& string) {
  char *s = string.getValue();
 HostFile& hfile = h << s;     // Put s on the host stream
 string.ungetValue();
 return hfile;
}

Using the << operator in my code, e.g. with

HostFile hout = Hostfile("foo.log");
String s = String("foo");
hout << s << '\n';

I get a fatal error in Pose: "... just executed an illegal or unknown
machine language instruction. The opcode ... was 0xFFF8"

If I put  the friend function into the default section, everything works
fine.

I have compiled the code with -fno-default-inline -fno-exceptions
-fno-rtti and linked it to libnoexcept.

Are there any restrictions to using friend functions in custom code
sections?

Cheers,

--Bernd Abel--


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

Reply via email to