<< Click to Display Table of Contents >> Navigation: Code Virtualizer > FAQ > Macros > Can Code Virtualizer macros protect switch statements and try-except clauses? |
Switch-Case statements and try-except clauses cannot work with Code Virtualizer macros in most compilers.
Compilers generate a direct jump table in the data section which directly jumps to each "case" statement. When the code is virtualized, the jump goes into a virtualized (garbage) code and it produces exception. You can use a workaround to protect your switch-case statements with Code Virtualizer macros, like:
switch (var) {
case 0:
VM_START
// your code
VM_END
case 1:
VM_START
// your code
VM_END
...
} |
For try-except clauses:
try { VM_START
// your code
VM_END
}
except {
VM_START
// your code
VM_END
} |