home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / examples / cxxsharedlib / cxxsltest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-24  |  1.2 KB  |  51 lines

  1. #include <iostream.h>
  2. #include "cxxsharedlib.h"
  3. #include <proto/exec.h>
  4.  
  5. struct Library *FOOBase;
  6. #define FOONAME "foo.library"
  7.  
  8. int _STI_4500_foo(void)
  9. {
  10.    FOOBase = OpenLibrary((unsigned char *)FOONAME, 0L);
  11.    if(FOOBase == NULL)
  12.    {
  13.       /*************************************************/
  14.       /* Note: We must use printf(), not cout, because */
  15.       /*       the iostreams library hasn't yet been   */
  16.       /*       initialized when this code is called.   */
  17.       /*       iostreams is initialized at priority    */
  18.       /*       4990, and we're running at priority     */
  19.       /*       4500.                                   */
  20.       /*************************************************/
  21.       printf("Can't open library \"" FOONAME "\"\n");
  22.       return -1;
  23.    }
  24.    printf("Library \"" FOONAME "\" opened\n");
  25.    return 0;
  26. }
  27.  
  28. void _STD_4500_foo(void)
  29. {
  30.    if(FOOBase) 
  31.    {
  32.       CloseLibrary(FOOBase);
  33.       FOOBase = NULL;
  34.       /* Use printf since iostreams has already been terminated */
  35.       printf("Library \"" FOONAME "\" closed\n");
  36.    }
  37. }
  38.  
  39.  
  40. FOO bar(20);
  41.  
  42. int main(void)
  43. {
  44.    FOO foo(10);
  45.    bar.foofunc(2);
  46.    bar.foofunc("Hello, this is bar");
  47.    foo.foofunc(4);
  48.    foo.foofunc("Hello, this is foo");
  49.    return 0;
  50. }
  51.