- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Example use:
+ * static struct mystruct *var = LTTNG_UST_COMPOUND_LITERAL(struct mystruct, { 1, 2, 3 });
+ */
+#if defined (__cplusplus) && defined (LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP)
+#define LTTNG_UST_COMPOUND_LITERAL(type, ...) new (type) __VA_ARGS__
+#else
+#define LTTNG_UST_COMPOUND_LITERAL(type, ...) (type[]) { __VA_ARGS__ }
+#endif
+
+/*
+ * Compile time assertion.
+ * - predicate: boolean expression to evaluate,
+ * - msg: string to print to the user on failure when `static_assert()` is
+ * supported,
+ * - c_identifier_msg: message to be included in the typedef to emulate a
+ * static assertion. This parameter must be a valid C identifier as it will
+ * be used as a typedef name.
+ */
+#ifdef __cplusplus
+#define lttng_ust_static_assert(predicate, msg, c_identifier_msg) \
+ static_assert(predicate, msg)
+#elif __STDC_VERSION__ >= 201112L
+#define lttng_ust_static_assert(predicate, msg, c_identifier_msg) \
+ _Static_assert(predicate, msg)
+#else
+/*
+ * Evaluates the predicate and emit a compilation error on failure.