home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / amiga / programm / 17473 < prev    next >
Encoding:
Text File  |  1992-12-17  |  2.6 KB  |  65 lines

  1. 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
  2. From: walker@twix.unx.sas.com (Doug Walker)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Does opening libraries require a fixed varname?
  5. Message-ID: <BzEqzo.B1A@unx.sas.com>
  6. Date: 17 Dec 92 14:30:59 GMT
  7. References: <BzDnFz.FM5@usenet.ucs.indiana.edu>
  8. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  9. Organization: SAS Institute Inc.
  10. Lines: 51
  11. Originator: walker@twix.unx.sas.com
  12. Nntp-Posting-Host: twix.unx.sas.com
  13.  
  14.  
  15. In article <BzDnFz.FM5@usenet.ucs.indiana.edu>, shulick@navajo.ucs.indiana.edu (Sam Hulick) writes:
  16. |> 
  17. |> If I wanted, for instance, to open intuition.library, does the line
  18. |> *HAVE* to be:
  19. |> 
  20. |> IntuitionBase = OpenLibr.......
  21. |> 
  22. |> Can it be something like "IBase = OpenLibrary(.." or "blech = Open..."
  23. |> In other words, does it matter what you call the variable?
  24. |> GadToolsBase, ExecBase, GfxBase, etc.
  25.  
  26. Yes, it must use the assigned name, unless you take extra steps.  There
  27. are two major ways that calling system functions work: via stubs, and 
  28. via pragmas.  If you call via a stub, the parameters get pushed on the
  29. stack like any other C call, then the stub pops them into the correct
  30. registers, LOOKS AT AN EXTERNAL VARIABLE TO GET THE LIBRARY BASE, and
  31. jumps to the library.  The external variable that it looks at is the
  32. IntuitionBase, GfxBase, etc. that you're referring to.
  33.  
  34. The alternate method is to use #pragma statements.  #pragmas specify
  35. the library base name, the number of parameters and which registers
  36. the parameters go into.  This allows the compiler to call the library
  37. function directly instead of going through the stubs.  The pragams
  38. provided with your compiler all specify IntuitionBase, GfxBase, etc.
  39. as the bases, so normally you would have to initialize them just
  40. like with stubs.  However, the variables can be local variables or
  41. preprocessor #defines; this kind of lets you get away from the
  42. IntuitionBase name if you like.  You can do this, for example:
  43.  
  44. #include <proto/intuition.h>  // Or <pragmas/intuition_pragmas.h>
  45.  
  46. #define IntuitionBase IBase
  47. struct Library *IBase;
  48.  
  49. void main(void)
  50. {
  51.    IBase = OpenLibrary("intuition.library", 0L);
  52.    ...
  53. }
  54.  
  55. |>     // Amiga 3000   ___ \ Sam Hulick: shulick@indiana.edu (NeXTmail OK!)
  56.  
  57. -- 
  58.   *****
  59. =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
  60.  *|. o.| ||                                          1200/2400/9600 Dual
  61.   | o  |//     For all you do, this bug's for you!
  62.   ====== 
  63. usenet: walker@unx.sas.com                            bix: djwalker 
  64. Any opinions expressed are mine, not those of SAS Institute, Inc.
  65.