When I use macros directly around some API calls I get errors in WinLicense saying that one of my START or END markers is missing. What's wrong?

<< Click to Display Table of Contents >>

Navigation:  WinLicense > FAQ > Protection Options >

When I use macros directly around some API calls I get errors in WinLicense saying that one of my START or END markers is missing. What's wrong?

Please, notice that macros are in fact "dummy" code that does nothing (it's just recognized by WinLicense). If you put the VM_END at the end of a procedure, the compiler might remove the VM_END code when optimizations are enabled. If you compile with optimizations disabled, you should not have any problems.  

 

The following code might generate a "missing" macro pair:

 

YourFunction()

{

   VM_START

   // your code goes here

   return;

   VM_END

}  

 

The compiler knows that after the "return" statement, no code is executed, so it won't generate code for the VM_END marker. To avoid the above problem, just put it like:

 

YourFunction()

{

   VM_START

   // your code goes here

   VM_END

   return;

}

 

Also, you might want to disable optimizations in those places where macros are used, to make sure that compiler optimizations won't remove any macro markers. For C/C++ language you can use the following directive:

 

#pragma optimize("", off)

YourFunction()

{

   VM_START

   // your code goes here

   return;

   VM_END

}

#pragma optimize("", on)

 

You should be able to use the same approach for other programming languages.