How to conditionally apply `@inline(never)` attribute?

the following appears to be invalid:

#if INLINE_BARRICADE
@inline(never)
#endif
static func 
...

is there a way to conditionally insert these @inline(never) attributes based on a compilation flag?

A bit contorted, but I assume this would work:

#if INLINE_BARRICADE
@inline(never)
func foo() { _foo() }
#else
func foo() { _foo() }
#endif

@inline(__always)
private func _foo() {
   print("foo!")
}
1 Like

Somewhat offtopic, but in which cases would you want to forbid inlining?

for performance profiling. the compiler is so aggressive it tends to turn the whole app into two or three stack frames, which is useless for profiling

1 Like

Is profiling a version of the binary with different/inhibited optimizations and thus different performance characteristics much more useful?

2 Likes