Skip to content

Commit 9c806c4

Browse files
committed
Cmake will generate the header which is needed.
Changes to be committed: modified: .gitignore modified: CMakeLists.txt new file: Macro.h.in modified: inc/ae2f/Macro.h
1 parent cb2c0cc commit 9c806c4

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ build/*
33

44
.*/
55

6-
*.auto.h
6+
*.auto.h
7+
inc/ae2f/Macro.h

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ include(cmake/Core.cmake)
88
include(cmake/Macro.cmake)
99

1010
if(NOT TARGET ae2f::Macro)
11+
configure_file(${PROJECT_SOURCE_DIR}/Macro.h.in ${PROJECT_SOURCE_DIR}/inc/ae2f/Macro.h)
1112
ae2f_CoreLibTent(Macro INTERFACE inc ae2f "inc/ae2f/Macro.h")
12-
endif()
13+
endif()

Macro.h.in

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#ifndef __ae2f_MACRO_GENERATED
2+
#define __ae2f_MACRO_GENERATED 0
3+
#endif
4+
5+
#undef ae2f_WhenMac
6+
#undef ae2f_WhenNMac
7+
#undef ae2f_MAC
8+
9+
#if !__ae2f_MACRO_GENERATED
10+
11+
/** Available when is macro-generated */
12+
#define ae2f_WhenMac(...)
13+
14+
/** Available when is not-macro-generated. */
15+
#define ae2f_WhenNMac(...) __VA_ARGS__
16+
17+
#else
18+
19+
/** Available when is macro-generated .*/
20+
#define ae2f_WhenMac(...) __VA_ARGS__
21+
22+
/** Available when is not-macro-generated. */
23+
#define ae2f_WhenNMac(...)
24+
25+
#endif
26+
27+
/**
28+
* @def ae2f_MAC
29+
* @brief
30+
* A hint for creating a macro from void-returning function.
31+
*
32+
* @details
33+
* Its parameters will be additional template parameters you could customise.
34+
* */
35+
#define ae2f_MAC(...) ae2f_WhenNMac(inline static void)
36+
37+
#if !(defined(OFF) && defined(ON))
38+
#define OFF 0
39+
#define ON 1
40+
#endif
41+
42+
#define ae2f_MAC_BUILD @ae2f_MAC_BUILD@

inc/ae2f/Macro.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@
3333
* Its parameters will be additional template parameters you could customise.
3434
* */
3535
#define ae2f_MAC(...) ae2f_WhenNMac(inline static void)
36+
37+
#if !(defined(OFF) && defined(ON))
38+
#define OFF 0
39+
#define ON 1
40+
#endif
41+
42+
#define ae2f_MAC_BUILD OFF

0 commit comments

Comments
 (0)