Site icon Bytefreaks.net

C/C++: An interresting macro to capture errors with perror, use custom error code number

Advertisements

#include <stdio.h>
#include <errno.h>
#define handle_error_ern(ern, msg) do { errno = ern; perror(msg); exit(EXIT_FAILURE); } while (0

Usage Example: handle_error_ern(s, “pthread_getaffinity_np”);

This post is also available in: Greek

Exit mobile version