Advertisement
STANAANDREY

error checks

Mar 9th, 2025
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <pthread.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <unistd.h>
  6. #define MIN(a, b) ((a > b) ? b : a)
  7.  
  8. #define CHECK_RETURN(func_call, msg) do { \
  9.     int r = (func_call); \
  10.     if (r != 0) { \
  11.       fprintf(stderr, "Error %s: %s\n", (msg), strerror(r)); \
  12.       exit(1); \
  13.     } \
  14.   } while (0)
  15.  
  16. #define CHECK_ERRNO(func_call, msg) do { \
  17.     int r = (func_call); \
  18.     if (r != 0) { \
  19.         perror(msg); \
  20.         exit(1); \
  21.     } \
  22.   } while (0)
  23.  
  24.  
  25. int main(int argc, char *argv[]) {
  26.  
  27.   return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement