From 630c304a2dff6be70717224e533c1ad6f01875e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20M=20G=C3=B3mez?= Date: Mon, 12 Aug 2024 17:10:17 +0100 Subject: [PATCH] Adds `SEQ_DECL_SIZE 1` back under `clang` and a test (#23942) --- lib/nimbase.h | 4 +++- tests/cpp/fam.h | 4 ++++ tests/cpp/tfam.nim | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/cpp/fam.h create mode 100644 tests/cpp/tfam.nim diff --git a/lib/nimbase.h b/lib/nimbase.h index 4674b64c89..cdbb68ff2c 100644 --- a/lib/nimbase.h +++ b/lib/nimbase.h @@ -475,7 +475,9 @@ typedef char* NCSTRING; } name = {{length, (NI) ((NU)length | NIM_STRLIT_FLAG)}, str} /* declared size of a sequence/variable length array: */ -#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) +#if defined(__cplusplus) && defined(__clang__) +# define SEQ_DECL_SIZE 1 +#elif defined(__GNUC__) || defined(_MSC_VER) # define SEQ_DECL_SIZE /* empty is correct! */ #else # define SEQ_DECL_SIZE 1000000 diff --git a/tests/cpp/fam.h b/tests/cpp/fam.h new file mode 100644 index 0000000000..ad576425bf --- /dev/null +++ b/tests/cpp/fam.h @@ -0,0 +1,4 @@ +struct Test{ + ~Test() { + } +}; diff --git a/tests/cpp/tfam.nim b/tests/cpp/tfam.nim new file mode 100644 index 0000000000..6bd89fe245 --- /dev/null +++ b/tests/cpp/tfam.nim @@ -0,0 +1,7 @@ +discard """ + targets: "cpp" +""" +type + Test {.importcpp, header: "fam.h".} = object + +let test = newSeq[Test]() \ No newline at end of file