homas Engelmeier < XXXX@XXXXX.COM > wrote in message news:< XXXX@XXXXX.COM >...
Insults are unnecessary. I am a professional programmer working in
C++, not C. I am new to the Mac, but not to C-based languages or
reference errors. The above code conforms to the models of working
code that I have scavenged to assist me in rapidly learning the
workings of a new platform.
PROCEDURE InsertMenuItem (theMenu: MenuHandle; itemString: Str255;
myMenuRef is a MenuHandle pointer, and it is properly dereferenced.
Therefore, the handle (which is a pointer to a pointer) should be
passed by value (i.e. the value of the masterpointer that points to
the pointer that points to the previously created Menu object.)
As stated above, I am working in C++. For compatability with third
party projects, I am limited to using the CodeWarrior IDE and the
Carbon environment, which necessitates the use of quite a few C calls
(unless I have misread the documentation I have thus far been using).
I am also passing objects and values back and forth between our
existing API (consisting of over a half-million lines of code and
somewhere around 100 classes) and the test project that instantiates
the API, and that will embed controls provided by it. In some
instances this will force me to use dynamically created objects
referenced by pointers rather than automatically instantiated objects
of limited scope, even if the function I am currently working with
requires a pass-by-value parameter.
Dereferencing a pointer to an object and passing it is no different
than passing by value, unless CodeWarrior has developed a strange new
paradigm that I am unaware of.
If I am passing a pointer as a value in the code snippet above when I
should not be, please point out my error rather than simply insulting
me. Again, I am following the documentation as closely as I can, but I
am discovering that many of the functions that I am using have
dependancies that are poorly documented. For instance, I have found
that many of my recent problems (including the one above) stem from
the lack of the CarbonFrameworkLib in my project. I created my sample
project from CodeWarrior's Mac OS Stationary C++ Carbon Toolbox Nib
Bundle, which does not include this library.
C++ disallows it too. As I stated before, this code returns no
compiler errors. Prehaps you did not notice the asterisk.
The pointer is dereferenced before it is passed, therefore the
myMenuRef variable it points to is passed by value and not by
reference. Again, If this is an overloaded function and I need to use
a different form of it, tell me so. Don't just assume that I have
passed it the wrong argument.
If you have any constructive criticism for me, I am all eyes and ears.
I have no problem confessing my ignorance on a new platform, but I
dislike being scolded like a child by someone who obviously didn't
read my post very carefully.