summaryrefslogtreecommitdiff
path: root/ext/-test-/RUBY_ALIGNOF/cpp.cpp
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-09-23 14:29:05 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-09-25 11:38:33 +0900
commit0b77a86d1ec3a8bb3d62ea38a93d7aed44dd2c0c (patch)
tree2671195ec447408d934a65fa21904dcf8b4c3909 /ext/-test-/RUBY_ALIGNOF/cpp.cpp
parent873fb1aa4cab7a14f2b38a05f5888c111ea3bc69 (diff)
ext/-test-/RUBY_ALIGNOF: add minimalistic test
Check if RUBY_ALIGNOF(double) is the alignment to store a double inside of a struct.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3570
Diffstat (limited to 'ext/-test-/RUBY_ALIGNOF/cpp.cpp')
-rw-r--r--ext/-test-/RUBY_ALIGNOF/cpp.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/-test-/RUBY_ALIGNOF/cpp.cpp b/ext/-test-/RUBY_ALIGNOF/cpp.cpp
new file mode 100644
index 0000000000..ea1211c38c
--- /dev/null
+++ b/ext/-test-/RUBY_ALIGNOF/cpp.cpp
@@ -0,0 +1,15 @@
+#include "ruby.h"
+#include <cstddef>
+
+struct T {
+ char _;
+ double t;
+};
+
+RBIMPL_STATIC_ASSERT(RUBY_ALIGNOF, RUBY_ALIGNOF(double) == offsetof(T, t));
+
+extern "C" void
+Init_RUBY_ALIGNOF()
+{
+ // Windows linker mandates this symbol to exist.
+}