home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!agate!stanford.edu!rock!concert!sas!mozart.unx.sas.com!walker
- From: walker@twix.unx.sas.com (Doug Walker)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Does opening libraries require a fixed varname?
- Message-ID: <BzEqzo.B1A@unx.sas.com>
- Date: 17 Dec 92 14:30:59 GMT
- References: <BzDnFz.FM5@usenet.ucs.indiana.edu>
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Organization: SAS Institute Inc.
- Lines: 51
- Originator: walker@twix.unx.sas.com
- Nntp-Posting-Host: twix.unx.sas.com
-
-
- In article <BzDnFz.FM5@usenet.ucs.indiana.edu>, shulick@navajo.ucs.indiana.edu (Sam Hulick) writes:
- |>
- |> If I wanted, for instance, to open intuition.library, does the line
- |> *HAVE* to be:
- |>
- |> IntuitionBase = OpenLibr.......
- |>
- |> Can it be something like "IBase = OpenLibrary(.." or "blech = Open..."
- |> In other words, does it matter what you call the variable?
- |> GadToolsBase, ExecBase, GfxBase, etc.
-
- Yes, it must use the assigned name, unless you take extra steps. There
- are two major ways that calling system functions work: via stubs, and
- via pragmas. If you call via a stub, the parameters get pushed on the
- stack like any other C call, then the stub pops them into the correct
- registers, LOOKS AT AN EXTERNAL VARIABLE TO GET THE LIBRARY BASE, and
- jumps to the library. The external variable that it looks at is the
- IntuitionBase, GfxBase, etc. that you're referring to.
-
- The alternate method is to use #pragma statements. #pragmas specify
- the library base name, the number of parameters and which registers
- the parameters go into. This allows the compiler to call the library
- function directly instead of going through the stubs. The pragams
- provided with your compiler all specify IntuitionBase, GfxBase, etc.
- as the bases, so normally you would have to initialize them just
- like with stubs. However, the variables can be local variables or
- preprocessor #defines; this kind of lets you get away from the
- IntuitionBase name if you like. You can do this, for example:
-
- #include <proto/intuition.h> // Or <pragmas/intuition_pragmas.h>
-
- #define IntuitionBase IBase
- struct Library *IBase;
-
- void main(void)
- {
- IBase = OpenLibrary("intuition.library", 0L);
- ...
- }
-
- |> // Amiga 3000 ___ \ Sam Hulick: shulick@indiana.edu (NeXTmail OK!)
-
- --
- *****
- =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
- *|. o.| || 1200/2400/9600 Dual
- | o |// For all you do, this bug's for you!
- ======
- usenet: walker@unx.sas.com bix: djwalker
- Any opinions expressed are mine, not those of SAS Institute, Inc.
-