Setting the condition of sourceinsight solves the problem of code syntax parsing errors.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.