An emulator, assembler, and disassembler for the Sega Game Gear
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

28 lignes
1.0 KiB

  1. /* Copyright (C) 2014 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #pragma once
  4. #include <errno.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. /* Internal usage only */
  8. #define LOG_MSG(level, extra, after, ...) { \
  9. fprintf(stderr, level ": " __VA_ARGS__); \
  10. extra; \
  11. fprintf(stderr, ".\n"); \
  12. after; \
  13. }
  14. #define PRINT_ERRNO() fprintf(stderr, ": %s", strerror(errno))
  15. /* Public error logging macros */
  16. #define FATAL(...) LOG_MSG("Error", {}, exit(EXIT_FAILURE), __VA_ARGS__)
  17. #define FATAL_ERRNO(...) LOG_MSG("Error", PRINT_ERRNO(), exit(EXIT_FAILURE), __VA_ARGS__)
  18. #define WARN(...) LOG_MSG("Warning", {}, {}, __VA_ARGS__)
  19. #define WARN_ERRNO(...) LOG_MSG("Warning", PRINT_ERRNO(), {}, __VA_ARGS__)
  20. #define OUT_OF_MEMORY() FATAL("couldn't allocate enough memory")