FWIW, I personally agree with the optimizer. If I have:
int publicint = 0;
And never reference publicint anywhere, it seems reasonable for the
optimizer to remove the memory object and the code that initializes it,
especially if I've asked for 'size' optimization.
<someclass> publicclass;
Is basically the same thing. A goal of C++ is to have 'user' created
types be identical behavior to built in types.
I would expect the optimizer to err on the safe said with 'volatile'.
If you declared your global C as 'volatile' or if declared the global
'int i' as 'volatile', I'd expect C to be included.
It would be nice if a warning was generated (ex. 'Unused global
variable...')
Best regards,
-jjf
-----Original Message-----
From: Greg Lutz [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 04, 2000 10:23 PM
To: Palm Developer Forum
Subject: Re: Another Debug-ROM catch
[Snip]
Create a project using C++ stationery (this example uses the
stock CW 6.0 release, with the PalmOS 3.0 SDK). Create the
following file "sub.cpp" and add it to the project:
#include <Pilot.h>
class C {
public:
C() {
ErrDisplay("Got here");
}
};
C c;
In the target settings dialog, set global optimizations to level
2. Build and execute the application(1). It will do nothing.
Now add the following function to Starter.cpp, just before PilotMain:
void f()
{
class C;
extern C c;
C* pc = &c;
}
Build the app again and execute it(2). Nothing happens.
Now add the following lines at the beginning of PilotMain:
int i = 0;
if (i) {
f();
}
Build the app again and execute it(3). Again, nothing happens.
Now set the global optimizations level from 2 down to 1. Build
the app once more and execute it(4). This time it displays the
message "sub.cpp, Line: 6, Got here".
[Snip]
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html