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


#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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.