Set the condition of sourceinsight to solve the problem of code syntax parsing errors

Source: Internet
Author: User
Set Sourceinsight of the condition resolves an issue with code syntax parsing errors   Author: Liu Xuhui Raymond Reprint Please specify the source email:colorant@163.com blog:http://blog.csdn.net/colorant/  Today use Sourceinsight encounter a very depressed problem, clearly exist function, source insight is not found, looked carefully, found the reason is as follows: similar to the following code, in the function F1, there is a #ifdef condition macro, In the two branches of the conditional macro, curly braces are used as the starting parenthesis for a section of code:   static void F1 () {       Some code;   #ifdef MACRO1        if (some judge) {#else        if (other judge ) {#endif                       Somecode;       //Source insight to match this parenthesis with the second if        Some more code; }//Source insight will match this parenthesis with the first if the   static void F2 () {       ...}   static void F3 () {       ...}     results, sourceinsight in parsing, when syntax matches, the curly braces in the two branches of a macro are counted, So in the matching process of the anti-parenthesis, virtually, so that the reverse bracket is one less, resulting in the function F1 the end of the back parenthesis, source INsight still think that the function does not end, so that the following F2 and F3 are considered part of the F1, so when looking at the code, source insight does not think there is F2 F3 these two functions.   This, really depressed, do not know how many kinds of similar situations cause code can not be parsed correctly. Influence or even mislead the reading comprehension of the program.   took a closer look at source Insight's user manual and found that there was a way to fix the problem afterwards.   in Options > Preferences:language can set condition, so-called condition is basically set identifier and its value. For example above, you can add an identifier named MACRO1 and set its value to 1. In this way, source insight, in the process of code parsing, parses or ignores the corresponding code according to condition. ,   After setting this condition, source insight can correctly match the braces in the above code and solve the problem. Do not know if there is a more flexible solution.   Because the ignored code will appear in gray, so you can add the value of the macro you can determine in the code, easy to read the code, visually determine 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.