Turn: easily implement visual c ++ source code specification

Source: Internet
Author: User

[Article info] http://www.yesky.com/SoftChannel/72342371928702976/20050228/1915727.shtml
 
Author: Zhang Yushan time: Source: Tianji net responsibility Editor: Fangzhou

[Document Introduction]
 
This article introduces an open-source code sorting tool named astyle and how to integrate the configuration in the VC development environment.

[Body]
 
 
 
If you are a VC programmer, Are you troubled by a problem? The project team has strict coding requirements, but the project progress is tight and a large amount of code needs to be completed every day. It is difficult to ensure the development progress and compile code with good style and indentation specifications. If you use other tools to organize the source code, you need to re-open the source code outside of VC. The results cannot be directly viewed and compiled in VC. Can I integrate a tool in VC to easily click the VC button to sort out the source code? The answer is yes.

Next I will introduce an open-source code sorting tool named astyle and how to integrate the configuration in the VC development environment. You can quickly implement the Code sorting function in VC, hoping to help you.

1. Visit http://sourceforge.net/projects/astyle, download the astylepackage, package the source file, executable file, and usage instructions.

2. Copy beiastyle.exe to C:/winnt/system32.

3. Configure VC and add the astyle code sorting function.

1) create a menu item "format sorting" in VC ". Right-click on the toolbar to open the Customize window. On the Tools tab, create a menu item: "", and enter the corresponding path of the plug-in tool program in command: "C: /winnt/system32/astyle.exe ".
 
 

2) In arguments, enter the plug-in tool program Configuration Parameter -- style = ANSI $ {filename }$ {fileext }. -- Style = ANSI indicates that the ANSI style format and indentation are used. Of course, you can also choose other styles. The optional styles and samples are as follows:

-- Style = ANSI: ANSI style format and indentation


Namespace foospace
{
Int Foo ()
{
If (isbar)
{
Bar ();
Return 1;
}
Else
Return 0;
}
}

-- Style = Kr: kernighan & Ritchie style format and indent

Namespace foospace {
Int Foo (){
If (isbar ){
Bar ();
Return 1;
} Else
Return 0;
}
}

-- Style = Linux: Linux style format and indentation

Namespace foospace
{
Int Foo ()
{
If (isbar ){
Bar ();
Return 1;
} Else
Return 0;
}
}

-- Style = GNU: GNU style format and indentation

Namespace foospace
{
Int Foo ()
{
If (isbar)
{
Bar ();
Return 1;
}
Else
Return 0;
}
}

-- Style = Java: Java style format and indentation

Class foospace {
Int Foo (){
If (isbar ){
Bar ();
Return 1;
} Else
Return 0;
}
}

For more detailed configuration parameters, see the astyle random document.

$ {Filename }$ {fileext}: indicates the source file being edited.

In initial directory, enter the $ (filedir) parameter to indicate the initial running path. After this parameter is set, the initial path of astyle startup is the current file path.

3) Select the "use output window" option to enable the DOS box to display the running result directly to VC when the code is compiled by astyle.exe ,.


4) to facilitate the use of the astyle tool, you can also add this menu item to the convenient toolbar. You can also set the tool icon number in customize under tools ,:

5) at this point, the setup is basically complete, and some precautions need to be noted. Because the source file in the hard disk is the object that astyle organizes the Code. If the source file is not saved, the VC will pop up the source File Reload prompt box. If yes, the code just developed will be lost, which is undoubtedly the most painful task for programmers. Selecting or not will make the sorting operation in vain. Therefore, to ensure that the development code is saved in time, you need to save and modify the source file before sorting. To implement this function, set save options to "save before running Tools ",:

Okay, it's done. You just need to easily click the VC toolbar button to organize the code, and the standard source code will appear in the VC editing box immediately.

Next, let's take a look at the pleasant results of using VC to integrate astyle into the code!

1. Messy code lines before sorting:

2. The code lines are as follows:

 

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.