mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 06:05:44 +01:00
define some more utility functionality
This commit is contained in:
15
src/error.h
15
src/error.h
@@ -5,18 +5,17 @@
|
||||
#if __INCLUDE_LEVEL__ > 0
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "util/macro.h"
|
||||
#endif
|
||||
|
||||
#define ERROR_STR_PRE(v) #v
|
||||
#define ERROR_STR(v) ERROR_STR_PRE(v)
|
||||
|
||||
#define debug(s, ...) printf("\033[95m" __FILE__ ":" ERROR_STR(__LINE__) ": [DBG]: " s "\033[0m\n", ##__VA_ARGS__)
|
||||
#define info(s, ...) printf(__FILE__ ":" ERROR_STR(__LINE__) ": [INF]: " s "\n", ##__VA_ARGS__)
|
||||
#define warn(s, ...) fprintf(stderr, "\033[93m" __FILE__ ":" ERROR_STR(__LINE__) ": [WAR]: " s "\033[0m\n", ##__VA_ARGS__)
|
||||
#define error(s, ...) fprintf(stderr, "\033[91m" __FILE__ ":" ERROR_STR(__LINE__) ": [ERR]: " s "\033[0m\n", ##__VA_ARGS__)
|
||||
#define debug(s, ...) printf("\033[95m" __FILE__ ":" MACRO_STR2(__LINE__) ": [DBG]: " s "\033[0m\n", ##__VA_ARGS__)
|
||||
#define info(s, ...) printf(__FILE__ ":" MACRO_STR2(__LINE__) ": [INF]: " s "\n", ##__VA_ARGS__)
|
||||
#define warn(s, ...) fprintf(stderr, "\033[93m" __FILE__ ":" MACRO_STR2(__LINE__) ": [WAR]: " s "\033[0m\n", ##__VA_ARGS__)
|
||||
#define error(s, ...) fprintf(stderr, "\033[91m" __FILE__ ":" MACRO_STR2(__LINE__) ": [ERR]: " s "\033[0m\n", ##__VA_ARGS__)
|
||||
|
||||
#define fatal(s, ...) \
|
||||
do { \
|
||||
printf("\033[101m" __FILE__ ":" ERROR_STR(__LINE__) ": [FAT]: " s "\033[0m\n", ##__VA_ARGS__); \
|
||||
printf("\033[101m" __FILE__ ":" MACRO_STR2(__LINE__) ": [FAT]: " s "\033[0m\n", ##__VA_ARGS__); \
|
||||
exit(1); \
|
||||
} while (0)
|
||||
|
||||
9
src/util/macro.h
Normal file
9
src/util/macro.h
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) 2025 Quinn
|
||||
// Licensed under the MIT Licence. See LICENSE for details
|
||||
#pragma once
|
||||
|
||||
#define MACRO_WIDTH(t) (sizeof(t) * 8) // gets the bit width of a type
|
||||
#define MACRO_CAT(x, y) x##y // concatenate two macro variables together
|
||||
#define MACRO_CAT2(x, y) MACRO_CAT(x, y) // concatenate two macro variables together
|
||||
#define MACRO_STR(v) #v // for converting macro variable into a string
|
||||
#define MACRO_STR2(v) MACRO_STR(v) // for a recursive string generation
|
||||
9
src/util/types.h
Normal file
9
src/util/types.h
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) 2025 Quinn
|
||||
// Licensed under the MIT Licence. See LICENSE for details
|
||||
#pragma once
|
||||
|
||||
/* integer types */
|
||||
typedef unsigned int uint; // ≥16 bit unsigned integer
|
||||
typedef unsigned long ulong; // ≥32 bit unsigned integer
|
||||
typedef signed long long llong; // ≥64 bit signed integer
|
||||
typedef unsigned long long ullong; // ≥64 bit unsigned integer
|
||||
Reference in New Issue
Block a user