Define macros for C linkage
This commit is contained in:
parent
ffb99a3644
commit
12f182f0cf
@ -25,6 +25,8 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define class_mem static
|
||||
#define BEGIN_C_LINKAGE extern "C" {
|
||||
#define END_C_LINKAGE }
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !ALIASES_H
|
||||
|
@ -15,7 +15,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef enum mem_access {
|
||||
@ -55,7 +55,7 @@ void *wapp_mem_util_alloc(void *addr, u64 size, MemAccess access,
|
||||
void wapp_mem_util_free(void *ptr, u64 size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !MEM_UTILS_H
|
||||
|
@ -17,8 +17,7 @@ internal inline CMDError get_command_output(FILE *fp, CMDOutHandling out_handlin
|
||||
char *out_buf, u64 buf_size);
|
||||
internal inline CMDError get_output_status(FILE *fp, i32 *status_out);
|
||||
|
||||
// clang-format off
|
||||
CMDResult run_command(CMDOutHandling out_handling, char *out_buf, u64 buf_size, ...) { // clang-format on
|
||||
CMDResult run_command(CMDOutHandling out_handling, char *out_buf, u64 buf_size, ...) {
|
||||
va_list args;
|
||||
va_start(args, buf_size);
|
||||
|
||||
|
@ -7,11 +7,10 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#define CMD_NO_EXIT(ERR) \
|
||||
((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
|
||||
#define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
|
||||
#define wapp_shell_commander_execute(HANDLE_OUTPUT, OUT_BUF, BUF_SIZE, ...) \
|
||||
run_command(HANDLE_OUTPUT, OUT_BUF, BUF_SIZE, __VA_ARGS__, "2>&1", NULL)
|
||||
|
||||
@ -41,12 +40,10 @@ struct commander_result {
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
CMDResult run_command(CMDOutHandling out_handling, char *out_buf, u64 buf_size, ...);
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !COMMANDER_H
|
||||
|
@ -8,13 +8,13 @@
|
||||
#include "terminal_colours.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
void print_coloured_text(const char *text, TerminalColour colour);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
|
@ -4,14 +4,14 @@
|
||||
#include "terminal_colours.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
void wapp_shell_termcolour_print_text(const char *text, TerminalColour colour);
|
||||
void wapp_shell_termcolour_clear_colour(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !TERM_COLOUR_H
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define TERMINAL_COLOURS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef enum {
|
||||
@ -28,7 +28,7 @@ typedef enum {
|
||||
} TerminalColour;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !TERMINAL_COLOURS_H
|
||||
|
@ -12,13 +12,13 @@
|
||||
#include <WinCon.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
void print_coloured_text(const char *text, TerminalColour colour);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "aliases.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#define NUMPARTS(...) \
|
||||
@ -19,7 +19,7 @@ void join_path(char *dst, u64 count, ...);
|
||||
void dirup(char *dst, u64 levels, const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !PATH_UTILS_H
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "aliases.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
/***************************************************************************/ //
|
||||
@ -49,7 +49,7 @@ void *wapp_mem_allocator_realloc_aligned(const Allocator *allocator, void *ptr,
|
||||
void wapp_mem_allocator_free(const Allocator *allocator, void **ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !MEM_ALLOCATOR_H
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct arena Arena;
|
||||
@ -53,7 +53,7 @@ void wapp_mem_arena_clear(Arena *arena);
|
||||
void wapp_mem_arena_destroy(Arena **arena);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !MEM_ARENA_H
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
/***************************************************************************/ //
|
||||
@ -51,7 +51,7 @@ void wapp_mem_arena_allocator_clear(Allocator *allocator);
|
||||
void wapp_mem_arena_allocator_destroy(Allocator *allocator);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !MEM_ARENA_ALLOCATOR_H
|
||||
|
@ -3,13 +3,13 @@
|
||||
|
||||
#include "mem_allocator.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
Allocator wapp_mem_libc_allocator(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !MEM_LIBC_H
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct bstr BasicString;
|
||||
@ -28,7 +28,7 @@ struct strvw {
|
||||
#define wapp_string_print(STR) (printf("%.*s\n", (i32)STR.size, STR.buf))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !BASIC_STRING_H
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct dstr String;
|
||||
@ -35,7 +35,7 @@ u64 wapp_dstr_capacity(const String *str);
|
||||
const char *wapp_dstr_to_cstr(const String *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !DSTR_H
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#define wapp_tester_result(PASSED) ((TestFuncResult){.name = __func__, .passed = PASSED})
|
||||
@ -27,7 +27,7 @@ typedef TestFuncResult(TestFunc)(void);
|
||||
void run_tests(TestFunc *func1, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !TESTER_H
|
||||
|
@ -4,14 +4,14 @@
|
||||
#include "tester.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
TestFuncResult test_libc_allocator(void);
|
||||
TestFuncResult test_arena_allocator(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !TEST_ALLOCATOR_H
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "tester.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
TestFuncResult test_arena_init(void);
|
||||
@ -17,7 +17,7 @@ TestFuncResult test_arena_clear(void);
|
||||
TestFuncResult test_arena_destroy(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !TEST_ARENA_H
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "tester.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
TestFuncResult test_commander_cmd_success(void);
|
||||
@ -13,7 +13,7 @@ TestFuncResult test_commander_cmd_out_buf_success(void);
|
||||
TestFuncResult test_commander_cmd_out_buf_failure(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
END_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !TEST_SHELL_COMMANDER_H
|
||||
|
Loading…
Reference in New Issue
Block a user