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

  1. #include <iostream.h>
  2. #include "cxxsharedlib.h"
  3.  
  4. __saveds __asm FOO::FOO(register __d1 int init)
  5. {
  6.    cout << "FOO::FOO(int) called with " << init << endl;
  7. }
  8.  
  9. __saveds __asm FOO::~FOO()
  10. {
  11.    cout << "FOO::~FOO() called" << endl;
  12. }
  13.  
  14. void __saveds __asm FOO::foofunc(register __d0 int intparm)
  15. {
  16.    cout << "FOO::foofunc(int) called with " << intparm << endl;
  17. }
  18.  
  19. void __saveds __asm FOO::foofunc(register __a1 char *ptrparm)
  20. {
  21.    cout << "FOO::foofunc(char *) called with \"" << ptrparm << "\"" << endl;
  22. }
  23.  
  24. #if DEBUGLIBINIT
  25. // The following function is here to allow us to debug the library
  26. // initialization code.  This is necessary if we want to debug constructors
  27. // called for static or external variables, for example.  If you try to
  28. // set a breakpoint on constructors or autoinitializers in a shared
  29. // library, it will not take effect until AFTER the OpenLibrary() call
  30. // returns to you!
  31. //
  32. // The process works like this:
  33. //
  34. //    1. Compile this file with the option DEFINE DEBUGLIBINIT=1.
  35. //    2. Make sure SegTracker and Enforcer are running.  They are shipped
  36. //       with SAS/C in the SC:EXTRAS drawer.
  37. //    3. Invoke CPR on the program that opens this library.  The program
  38. //       will stop before it gets to main() due to an enforcer hit.
  39. //       The source window will show assembly language source.
  40. //    4. Enter the following command in the dialog window:
  41. //
  42. //          symload pc pc "pathname"
  43. //
  44. //       (yes, you enter the letters "pc" twice in a row!)
  45. //
  46. //       "pathname" is the name of the .library file on disk,
  47. //       surrounded by double quotes.
  48. //
  49. //       (Note: If the .library file is in the current directory,
  50. //        you can abbreviate the above command to simply "symload".)
  51. //    5. At this point, you can enter breakpoints for C++ constructors
  52. //       and use the GO command as if the library were a normal program.
  53. //
  54. //    NOTE: When compiled with DEFINE DEBUGLIBINIT=1, your shared library
  55. //          will generate one enforcer hit each time it is opened by a
  56. //          program!  The enforcer hit is harmless, but it would probably
  57. //          be a pretty good idea not to ship a product with it enabled...
  58.  
  59. static long __tmpvar;
  60. int _STI_1_debug(void)
  61. {
  62.    volatile long *a = 0;   // Must be volatile so the optimizer leaves it
  63.    __tmpvar = *a;  // Cause an enforcer hit
  64.    return 0;
  65. }
  66. #endif
  67.