Skip to content

Commit a260e0f

Browse files
committed
What to do without __asm__?
1 parent 14d71d2 commit a260e0f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Documentation/Porting.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,27 @@ respectively. Their linker-level names will be platform-dependent: refer to the
180180
linker documentation for your platform to determine what names to place in the
181181
`__asm__` attribute applied to each.
182182

183+
If you can't use `__asm__` on your platform, you can declare these symbols as
184+
C++ references to linker-defined symbols:
185+
186+
```diff
187+
diff --git a/Sources/_TestingInternals/Discovery.cpp b/Sources/_TestingInternals/Discovery.cpp
188+
// ...
189+
+#elif defined(macintosh)
190+
+extern "C" const char __linker_defined_begin_symbol;
191+
+extern "C" const char __linker_defined_end_symbol;
192+
+static const auto& sectionBegin = __linker_defined_begin_symbol;
193+
+static const auto& sectionEnd = __linker_defined_end_symbol;
194+
#else
195+
#warning Platform-specific implementation missing: Runtime test discovery unavailable (static)
196+
static const char sectionBegin = 0;
197+
static const char& sectionEnd = sectionBegin;
198+
#endif
199+
```
200+
201+
The names of `__linker_defined_begin_symbol` and `__linker_defined_end_symbol`
202+
in this example are, as with the shorter implementation, platform-dependent.
203+
183204
## C++ stub implementations
184205

185206
Some symbols defined in C and C++ headers, especially "complex" macros, cannot

0 commit comments

Comments
 (0)