Set
Sourceinsight
Of
Condition
SolutionCodeSyntax Parsing Error Author: Liu Xuhui Raymond reprinted please indicate the source email: colorant@163.com blog: http://blog.csdn.net/colorant/ today when using sourceinsight encountered a very depressing problem, clearly exist function, source insight is not found, after reading the code carefully, we find that the cause is as follows: similar to the following code, in function F1, there is a # ifdef conditional macro, in the two branches of the conditional macro, braces are used as the starting brackets for a code range: static void F1 (){ Some code; # Ifdef macro1 If (some judge ){ # Else If (other judge ){ # Endif Somecode; } // Source insight Match the brackets with the second if. Some more code; } // Source insight matches the bracket with the first if with static void F2 (){ ... } Static void F3 (){ ... } Result: during parsing, the braces in the two branches of the macro are counted during syntax matching. Therefore, during the matching process of the parentheses, as a result, the parentheses at the end of function F1 are missing. Source insight still thinks that the function is not over, so the following F2 and F3 are considered part of F1, so when you look at the code, source insight does not think there are F2 F3 functions. This is a bit depressing. I don't know how many similar situations will lead to code failure to be correctly parsed. The impact is even misleading. Program . After carefully reading the user manual of source insight, we found that there is a way to fix the problem after the event. You can set condition in Options> preferences: language. The so-called condition basically sets the identifier and its value. For example, in the preceding example, you can add an identifier named macro1 and set its value to 1. In this way, the source insight parses or ignores the corresponding code according to the condition in the code parsing process. After the condition is set, source insight can correctly match the braces in the above Code and solve the problem. I wonder if there is any more flexible solution. Because the ignored code is displayed in gray, you can add the macro values that you can determine in the Code to facilitate reading the code and intuitively judge the valid code.