[comp.sys.mac.programmer] Linking cdevs

mm3d+@andrew.cmu.edu (Matt McNally) (11/02/88)

     What follows is an excerpt from the Inside Macintosh Volume V
Sample cdev with working 'Compile and linking' parameters.  I
have included the header for the pascal source in an
attempt to clear up any of the confusion inherent with
linking the cdev.

===== Start of Code Excerpt =====

{ *** Sample.p ***: Sample MPW 2.0 source code for a Macintosh CDEV.
                    All Pascal and Rez sources extracted from
                   Inside Macitntosh V pp.336-345  -MMM [10/30/88]}


{ Copyright (C) 1986,1987 Apple Computer, Inc.
                         All rights reserved. Etc etc.}

{ The 'main' cdev function name has been changed from 'Sample' as it
  appears in Inside Macintosh V to 'CDEVSAMP' to clarify the link statement.}

(*  === Working Compilation Parameters ===
        pascal cample.p
        Rez sample.r -o sample
        Link -m CDEVSAMP -sn Main=Sample sample.p.o
               "{Libraries}"Interface.o
               "{PLibraries}"PasLib.o
               -o Sample
               -rt 'cdev'=-4064
               -c 'samp' -t 'cdev'

        SetFile -a BIM Sample
*)

Unit cdev;

Interface

Uses
        { $Load Sample.dump }          { <== Used for 'speedy' compilation...}
        Memtypes, QuickDraw, OSIntf, ToolIntf, PackIntf;
        { $Load }

Function CDEVSAMP(message, item, numItems, CPanelID:Integer;
                 theEvent: EventRecord; cdevValue: LongInt;
                 CPDialog:DialogPtr) :LongInt;

Implementation
...{ cdev specific code here [see notes below] }...

End;   { End of Unit cdev }

===== End of Code Excerpt =====


Notes:

        1) The CDEVSAMP function must be the first code in the 'code' resource.

        2) The new 256K ROMS support 'PACK' 7, so you need to either
           check which machine you are on and NOT load it if the machine
           supports the new ROMS, or simply remove the code in Sample.p that
           refences that package.  After all this is only a sample...

Many thanks to -
    William Bumgarner, Ken McLeod, Larry Rosenstein,
        Barry Semo, and Robert White
               - for their invaluable help concerning cdevs and linking.

If you would like a copy of the 'rez' and/or 'pascal' sources for the
above sample cdev send me mail at mm3d@andrew.cmu.edu.
==========================================================================
Matt McNally  Macintosh II Project Dugan/Programmer
              Carnegie Mellon, College of Humanities and Social Sciences
              ARPANET: mm3d@andrew.cmu.edu  Office: BH239 (412) 268-8454
==========================================================================