fix: More C++ support.

This commit is contained in:
2025-06-29 02:52:53 +02:00
parent 1401e1d70b
commit 1aba159f8f
4 changed files with 22 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
#ifndef __cplusplus
#define _GNU_SOURCE #define _GNU_SOURCE
#endif
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@@ -7,14 +8,16 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/shm.h> #include <sys/shm.h>
#ifdef __cplusplus
#include <cstdio>
#endif
#include "utils.h" #include "utils.h"
#ifndef INCLUDE_SET_H #ifndef INCLUDE_SET_H
#define INCLUDE_SET_H #define INCLUDE_SET_H
#define SET_MAX_ERROR_MSG_SIZE 256
#define SET_MAX_NAME_SIZE 64
/** /**
* Meta data for one test function. * Meta data for one test function.
* *

View File

@@ -25,7 +25,8 @@ void set_ll_free_all(struct SETBlockMeta *head)
struct SETBlockMeta *set_ll_free_one(struct SETBlockMeta *head, void *address) struct SETBlockMeta *set_ll_free_one(struct SETBlockMeta *head, void *address)
{ {
struct SETBlockMeta *meta = address - (sizeof(struct SETBlockMeta)); struct SETBlockMeta *meta =
(struct SETBlockMeta *)address - (sizeof(struct SETBlockMeta));
if (meta->prev == NULL) if (meta->prev == NULL)
{ {

View File

@@ -48,7 +48,7 @@ int create_shared_suit_space(size_t size)
void *set_malloc(size_t n) void *set_malloc(size_t n)
{ {
void *blocks = malloc(n + sizeof(struct SETBlockMeta)); void *blocks = malloc(n + sizeof(struct SETBlockMeta));
struct SETBlockMeta *meta = blocks; struct SETBlockMeta *meta = (struct SETBlockMeta *)blocks;
meta->next = NULL; meta->next = NULL;
meta->prev = NULL; meta->prev = NULL;

12
testtest.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include "set.h"
#include "set_asserts.h"
NO_SETUP;
NO_TEAR_DOWN;
TEST(Basic) { ASSERT_EQ(1, 1); }
SUIT(Basic) { ADD_TEST(Basic); }
BUNDLE() { ADD_SUIT(Basic); }