Skip to content

Instantly share code, notes, and snippets.

@one2blame
Last active June 8, 2022 05:06
Show Gist options
  • Save one2blame/5010e9b49fed5402a1aa3c97b6682b1f to your computer and use it in GitHub Desktop.
Save one2blame/5010e9b49fed5402a1aa3c97b6682b1f to your computer and use it in GitHub Desktop.
Useful print macros
#define _GNU_SOURCE
include <stdio.h>
#define print_info(string, ...) \
do \
{ \
printf("[*] %s: " string, program_invocation_name, ##__VA_ARGS__); \
} while (0)
#define print_err(string, ...) \
do \
{ \
fprintf(stderr, "[!] %s: %s @ %d: " string, \
__FILE__, \
__FUNCTION__, \
__LINE__, \
##__VA_ARGS__); \
} while (0)
// Clears the screen
#define clrscr() printf("\e[1;1H\e[2J")
// I think this is provided by glibc
// Just contains the name of the program - argv[0]
extern char* program_invocation_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment