Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
901 B

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. throw.cpp
  5. Abstract:
  6. This module implements a program which tests C++ EH.
  7. Author:
  8. David N. Cutler (davec) 25-Jun-2001
  9. Environment:
  10. User mode.
  11. Revision History:
  12. None.
  13. --*/
  14. #include <windows.h>
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <string.h>
  18. #include <malloc.h>
  19. VOID
  20. func (
  21. ULONG N
  22. )
  23. {
  24. if (N != 0) {
  25. throw N;
  26. }
  27. return;
  28. }
  29. //
  30. // Main program.
  31. //
  32. int
  33. __cdecl
  34. main(
  35. int argc,
  36. char *argv[],
  37. char *envp[]
  38. )
  39. {
  40. try {
  41. func(5);
  42. printf("resuming, should never happen\n");
  43. } catch(ULONG) {
  44. printf("caught ULONG exception\n");
  45. } catch(CHAR *) {
  46. printf("caught CHAR * exception\n");
  47. } catch(...) {
  48. printf("caught typeless exception\n");
  49. }
  50. printf("terminating after try block\n");
  51. return 0;
  52. }