Monado OpenXR Runtime
u_vector.h
Go to the documentation of this file.
1// Copyright 2022, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Expose std::vector to C
6 * @author Mateo de Mayo <mateo.demayo@collabora.com>
7 * @ingroup aux_util
8 */
9
10#pragma once
11
12#include <stddef.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#define U_VECTOR_DECLARATION(TYPE) \
19 struct u_vector_##TYPE \
20 { \
21 void *ptr; \
22 }; \
23 struct u_vector_##TYPE u_vector_##TYPE##_create(); \
24 void u_vector_##TYPE##_push_back(struct u_vector_##TYPE uv, TYPE e); \
25 TYPE u_vector_##TYPE##_at(struct u_vector_##TYPE uv, size_t i); \
26 void u_vector_##TYPE##_destroy(struct u_vector_##TYPE *uv);
27
28U_VECTOR_DECLARATION(int)
29U_VECTOR_DECLARATION(float)
30
31#ifdef __cplusplus
32}
33#endif