8000 Add hsc2hs alignof macro · LumiGuide/haskell-opencv@8848577 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8848577

Browse files
committed
Add hsc2hs alignof macro
1 parent 2979834 commit 8848577

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

opencv/include/hsc_macros.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This files defines some hsc2hs macros. For documentation on how to construct cus
99
#include <bindings.dsl.h>
1010

1111
#define bc_sizeof_varid(name) {printf("c'sizeof_");bc_word(name);}; \
12+
#define bc_alignof_varid(name) {printf("c'alignof_");bc_word(name);}; \
1213

1314
/*
1415
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:
2728
bc_sizeof_varid(# name);printf(" = %lu\n", sizeof(name)); \
2829
}; \
2930

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+
3050
#endif /* __HSC_MACROS_H__ */

0 commit comments

Comments
 (0)
0