Skip to content

Commit

Permalink
libcyaml: fix static_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 committed May 22, 2024
1 parent 6c04934 commit a4705f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions devel/libcyaml/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ checksums rmd160 b3ed61d7d628188055fc5a7927171605d236f581 \
sha256 8dbd216e1fce90f9f7cca341e5178710adc76ee360a7793ef867edb28f3e4130 \
size 86791

# https://github.com/tlsa/libcyaml/pull/231
patchfiles-append 0001-data.h-use-_Static_assert-when-static_assert-undefin.patch

compiler.c_standard 2011

depends_lib-append port:libyaml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 2a5f98ed1d4d8e8b8c6c1850c5cbbe29dff08c94 Mon Sep 17 00:00:00 2001
From: barracuda156 <[email protected]>
Date: Wed, 22 May 2024 14:43:57 +0800
Subject: [PATCH] data.h: use _Static_assert when static_assert undefined

Fixes: https://github.com/tlsa/libcyaml/issues/230
---
src/data.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git src/data.h src/data.h
index 8b76a9c..4a00e4f 100644
--- src/data.h
+++ src/data.h
@@ -12,6 +12,13 @@
#ifndef CYAML_DATA_H
#define CYAML_DATA_H

+#include <assert.h>
+#if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \
+ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
+ && __STDC_VERSION__ <= 201710L
+#define static_assert _Static_assert
+#endif
+
#include "cyaml/cyaml.h"
#include "util.h"

0 comments on commit a4705f6

Please sign in to comment.