File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ This files defines some hsc2hs macros. For documentation on how to construct cus
9
9
#include < bindings.dsl.h>
10
10
11
11
#define bc_sizeof_varid (name ) {printf (" c'sizeof_" );bc_word (name);}; \
12
+ #define bc_alignof_varid (name ) {printf (" c'alignof_" );bc_word (name);}; \
12
13
13
14
/*
14
15
The #sizeof macro outputs a Haskell constant with the size of the C/C++ type in bytes.
@@ -27,4 +28,23 @@ Results in the following Haskell code:
27
28
bc_sizeof_varid (# name);printf (" = %lu\n " , sizeof (name)); \
28
29
}; \
29
30
31
+ /*
32
+ The #alignof macro outputs a Haskell constant with the alignment off the C/C++ type in bytes.
33
+
34
+ For example the following:
35
+
36
+ #alignof Point2i
37
+
38
+ Results in the following Haskell code:
39
+
40
+ c'alignof_Point2i :: Int
41
+ c'alignof_Point2i = 4
42
+
43
+ The specific alignment that is calculated is platform dependent.
44
+ */
45
+ #define hsc_alignof (name ) \
46
+ { bc_alignof_varid (# name);printf (" :: Int\n " ); \
47
+ bc_alignof_varid (# name);printf (" = %lu\n " , alignof (name)); \
48
+ }; \
49
+
30
50
#endif /* __HSC_MACROS_H__ */
You can’t perform that action at this time.
0 commit comments