[comp.sys.mac.programmer] C++ and MacApp

mm5l+@andrew.cmu.edu (Matthew Mashyna) (11/04/89)

I just got my copy of C++ and I tried to build a nothing application
using the MacApp headers. I can't figure it out. I get all kind of
typedef errors. I fix one and then I get more. I'm doing something
wrong. I tried to include UMacApp.h and UPrinting.h . Can someone point
me to a page in ANY manual that gives ANY details about using C++ and
MacApp together ? All I could find is instructions on linking to Object
Pascal. That's not much use when you can't compile anything. This is
making me sick. There isn't even any mention of the C++ MacApp headers
Disk in the manual(s) at all! Someone please make a fool of me and show
me where I missed it in the manual.


Matt Mashyna
Macintosh Initiative,
H&SS Dean's Office

jnh@ecemwl.ncsu.edu (Joseph N. Hall) (11/04/89)

In article <UZIS0k600iLO0Gw1go@andrew.cmu.edu> mm5l+@andrew.cmu.edu (Matthew Mashyna) writes:
>I just got my copy of C++ ... There isn't even any mention of the C++ MacApp 
>headers Disk in the manual(s) at all! Someone please make a fool of me and 
>show me where I missed it in the manual.

I get the impression that the MacApp headers were released in the hope that
someone would be able to get them running and would then describe the
patches and corrections required to someone at Apple DTS.  1/2 :-)

Look at the very bottom of the stack of documentation you got.  There are
about a half dozen pages about the headers.  They were included very late
in the release.

v   v sssss|| joseph hall                      || 4116 Brewster Drive
 v v s   s || jnh@ecemwl.ncsu.edu (Internet)   || Raleigh, NC  27606
  v   sss  || SP Software/CAD Tool Developer, Mac Hacker and Keyboardist
-----------|| Disclaimer: NCSU may not share my views, but is welcome to.

shebanow@Apple.COM (Andrew Shebanow) (11/05/89)

As the person who wrote those release notes, and as a DTS
engineer, I could explain to you all Apple's reasons for
sending out the MacApp headers, and give you the latest
information on fixing the problems with them as shipped.

You are right that they were included as a last minute
thing. The original plan was for the headers to be
released as part of MacApp 2.0 Final along with a set of
samples, real release notes, etc etc. However, Tim
Swihart, the C++ Product Manager, and Steve Burbeck,
the MacApp Product Manager, both realized that having
the headers could be of immense value to C++ users,
so they released them even though they had never undergone
any official testing and they were never intended to be
part of the C++ product. I think they both deserve a
lot of credit for going beyond official policy to do
"the right thing" for our developers.

Where things went slightly wrong is that everyone who used the
headers here did so using a prerelease version of MPW
3.1 (coming soon to an APDA near you). MPW 3.1 includes
a new version of Types.h, and people who tried the headers
using MPW 3.0 have been having a lot of difficulty.
The headers themselves aren't buggy (as yet, we haven't gotten
any bug reports from the field that weren't related to
the Types.h problem), its just that the C++ headers
depend on a missing C include file. If we had done the
official testing, we would have caught this bug, but that
would have either a) delayed the C++ product by weeks (or
months) or b) forced C++ users to wait weeks (or months)
for MacApp 2.0 final to be released. Neither of these
choices seems particularly attractive to me.

So the question is, which would you rather have:
slightly buggy headers, or no headers at all?

Anyhow, here is a release note that is being sent to
everyone who bought MPW 3.1b1 C++ from APDA (and they
aren't even charging for it!!!).

Have fun,

Andy Shebanow
MacDTS

----------------------------------------------------------------------
Release Notes for the MacApp 2.0b9 C++ Headers - The Sequel
October 20, 1989

Due to an unfortunate oversight, there are some problems
with the MacApp 2.0b9 C++ Headers - must have been the
earthquake. 

Types.h Problem

The MacApp 2.0b9 C++ Headers distributed with MPW C++ 3.1b1
depend on the Types.h file from the as-yet-unreleased MPW
3.1. Fortunately, you can fix this by adding the following
lines to the Types.h included with MPW 3.0: 

enum {v,h};
typedef unsigned char VHSelect;

typedef unsigned char Byte;
typedef char SignedByte;

You should also replace the definition of the Length macro with:

#ifdef __cplusplus
inline int Length(const StringPtr string) { return (*string); };
#else
#define Length(string) (*(unsigned char *)(string))
#endif

Your MacApp/C++ programs will now compile much more happily.

Speedup Hints

Your MacApp/C++ compiles will be a lot faster if you use a
global file to include all of your source files. About
80-90% of a typical compile is spent reading the MacApp
header files, so reading them once for all source files
instead of once for each source file is a big win. Your
global file would look something like this: 

// All.cp

#include "MMyProgram.cp"
#include "UMyProgram.cp"
#include "UUtilities.cp"

In your individual source files, bracket your MacApp
includes so that they don't get read more than once: 

// UUtilities.cp

#ifndef __UMacApp__
#include <UMacApp.h>
#endif __UMacApp__

#ifndef __UMacAppUtilities__
#include <UMacAppUtilities.h>
#endif __UMacAppUtilities__

#ifndef __UUtilities__
#include "UUtilities.h"
#endif __UUtilities__

// code....

Of course, you also need to put bracketing into your local
include files so that things don't go haywire if you do
include the same file twice: 

// UUtilities.h

#ifndef __UUtilities__

#define __UUtilities__ 1

// definitions

#endif __UUtilities__

----------------------------------------------------------------------

keith@Apple.COM (Keith Rollin) (11/06/89)

In article <UZIS0k600iLO0Gw1go@andrew.cmu.edu> mm5l+@andrew.cmu.edu (Matthew Mashyna) writes:
>I just got my copy of C++ and I tried to build a nothing application
>using the MacApp headers. I can't figure it out. I get all kind of
>typedef errors. I fix one and then I get more. I'm doing something
>wrong. I tried to include UMacApp.h and UPrinting.h . Can someone point
>me to a page in ANY manual that gives ANY details about using C++ and
>MacApp together ? All I could find is instructions on linking to Object
>Pascal. That's not much use when you can't compile anything. This is
>making me sick. There isn't even any mention of the C++ MacApp headers
>Disk in the manual(s) at all! Someone please make a fool of me and show
>me where I missed it in the manual.

*YOU* didn't miss anything. We did. We forgot to include an updated Types.h
file that you need. A release note for the C++ release notes should be posted
to this forum in a day or two that explains what you need to do.

These problems only happen with Types.h file that comes with MPW 3.0. They'll be
fixed in the next version of MPW.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

keith@Apple.COM (Keith Rollin) (11/06/89)

In article <4418@ncsuvx.ncsu.edu> jnh@ecemwl.UUCP (Joseph N. Hall) writes:
>In article <UZIS0k600iLO0Gw1go@andrew.cmu.edu> mm5l+@andrew.cmu.edu (Matthew Mashyna) writes:
>>I just got my copy of C++ ... There isn't even any mention of the C++ MacApp 
>>headers Disk in the manual(s) at all! Someone please make a fool of me and 
>>show me where I missed it in the manual.
>
>I get the impression that the MacApp headers were released in the hope that
>someone would be able to get them running and would then describe the
>patches and corrections required to someone at Apple DTS.  1/2 :-)

Pretty close. They were released with the message "well, you asked for them so
here they are. we were able to compile at least one program with them 
successfully, but make no guarantees as to real life experience. but what do 
you expect from a beta product? we'll come out with a Final version later when
we have more time."

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

mm5l+@andrew.cmu.edu (Matthew Mashyna) (11/06/89)

Thanks to the folks at Apple, and in particular Larry Rosenstein, for
setting me straight on this. 

Sorry I got a bit flustered. I should know better than to panic about
Beta software. I've had plenty panic about my early releases.

In case anyone else can't sit still long enough to read two thick inches
of documentation, here's what I had to do to get my copy of the C++
MacApp headers to work:

In Types.h I had to typedef VHSelect and SignedByte and redefine the
Length Macro as follows:

enum {v,h};
typedef unsigned char VHSelect;
 
typedef unsigned char Byte;
typedef char SignedByte;

and 

#ifdef __cplusplus
inline int Length(const StringPtr string) { return (*string); };
#else
#define Length(string) (*(unsigned char *)(string))
#endif


Matt Mashyna
Macintosh Initiative,
H&SS Dean's Office
Carnegie Mellon