Skip to content

Instantly share code, notes, and snippets.

@gsrunion
Created December 29, 2019 14:55
Show Gist options
  • Save gsrunion/a825009a9efe6874c0a7726c5a4d45f8 to your computer and use it in GitHub Desktop.
Save gsrunion/a825009a9efe6874c0a7726c5a4d45f8 to your computer and use it in GitHub Desktop.
#include "Boolean.h"
struct Boolean Boolean = {
0,
1,
};
#ifndef UNTITLED1_BOOLEAN_H
#define UNTITLED1_BOOLEAN_H
typedef struct boolean {
int value;
};
struct Boolean {
int true;
int false;
};
extern struct Boolean Boolean;
#endif
#include <stdio.h>
#define typename(x) _Generic((x), /* Get the name of a type */ \
\
char: "unsigned char", \
char: "char", signed char: "signed char", \
short int: "short int", unsigned short int: "unsigned short int", \
int: "int", unsigned int: "unsigned int", \
long int: "long int", unsigned long int: "unsigned long int", \
long long int: "long long int", unsigned long long int: "unsigned long long int", \
float: "float", double: "double", \
long double: "long double", char *: "pointer to char", \
void *: "pointer to void", int *: "pointer to int", \
int main() {
char* s = typename(char);
printf("Hello, World!\n");
return 0;
}
#include "Boolean.h"
struct Boolean Boolean = {
0,
1,
};
#ifndef UNTITLED1_BOOLEAN_H
#define UNTITLED1_BOOLEAN_H
typedef struct boolean {
int value;
};
struct Boolean {
int true;
int false;
};
extern struct Boolean Boolean;
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment