.[ ČeskéHry.cz ].

Laboratoř ČeskýchHer.cz - PasteBin

Vložit nový kód

ČeskéHry.cz - KOMUNITA HERNÍCH VÝVOJÁŘŮ

  1. 2025060311h13min27sec
    11 min
  2. 2025060311h02min13sec
    23 min
  3. 2025060310h50min57sec
    34 min
  4. 2025060310h39min36sec
    45 min
  5. 2025060310h28min26sec
    56 min
  6. 2025060310h17min01sec
    1 hod
  7. 2025060310h05min26sec
    1 hod
  8. 2025060309h53min52sec
    1 hod
  9. 2025060309h42min29sec
    1 hod
  10. 2025060309h31min01sec
    1 hod
Link: http://nopaste.ceske-hry.cz/subdom/nopaste222774
Zaslal: bolejt
Popis: obsah hlavičkového souboru exit.hpp. díky tomuhle je možné rozšířit funkcionalitu C++ kódu využívajícího "exit(returnCode);" tak, aby se správně zavolaly destruktory.
Jazyk: C++
Vloženo: 15.11.2009, 19:13
Stáhnout jako soubor
  1. // License: "Code is yours. Take it. Rape it. It's yours."
  2.  
  3. #ifndef _EXIT_HPP
  4. #define _EXIT_HPP
  5.  
  6. struct _ProgramExitException {
  7. int returnCode;
  8. _ProgramExitException(int returnCode) : returnCode(returnCode) {}
  9. };
  10.  
  11. #define exit(returnCode) throw _ProgramExitException(returnCode);
  12.  
  13. // funguje pouze pro "int main(int,char**)"
  14. // jednoduché přepsat pro jinou formu funkce main
  15. #define main(a,b) \
  16. _falseMain(int argc, char** argv); \
  17. int main(int argc, char** argv) { \
  18. try { \
  19. return _falseMain(argc,argv); \
  20. } \
  21. catch (_ProgramExitException& ex) { \
  22. return ex.returnCode; \
  23. } \
  24. return 0; \
  25. } \
  26. int _falseMain(a, b)
  27.  
  28. #endif /* _EXIT_HPP */
  29.