, VB.NET에서 처리기 지시문 매크로를 정의 할 수 없습니다
. 그러나 가장 가까운 대안은 함수를 정의하고 해당 함수에 대해 적극적인 인라인을 사용하도록 컴파일러에 요청하는 것입니다. 특정 조건이 충족되면 함수를 인라인으로 만드는 것은 JIT 결정입니다. (코드 크기 함수 < 32 바이트 ...)
이 .NET 버전 4.5 이상에서지지된다.
Imports System.Runtime.CompilerServices 'This is needed to define the aggressive inlining constant
Class TestClass
<MethodImplAttribute(MethodImplOptions.AggressiveInlining)> 'This will instruct compiler to use aggressive inlining if possible. Should be just before the function definition
Public Function MyFunc(ByVal A As Integer, ByVal B As Integer) As Integer
Return (A * A + B * B + 2 * A * B) 'An example function which should be inlined
End Function
End Class
나는 그것이 가능하다고 믿지 않는다. ([this] (http://stackoverflow.com/questions/4952413/vb-net-is-there-a-way-to-create-a-pre- processor-constant-that-as-a-simple)은 일종의 속임수입니다. 그러나 [this] (http://stackoverflow.com/a/23063080/2278086)는 성능에 도움이 될 수 있습니다. – Mark
Mark에게 감사드립니다. 귀하의 링크가 정말 유용합니다! –
누구나 그 매크로를 C 또는 C++로 쓸 수있는 합법적 인 이유가 없습니다. 그래서 VB.NET에서는 할 수 없으므로 아무 것도 잃지 않습니다. –