IAR template-how to create and use a template in the IAR Project

Source: Internet
Author: User

How to create and use templates in an IAR Project


1. Editing and using templates:


The path is edit-> code templates-> edit templates, for example:



After creating a template, right-click the file and select insert template to insert the edited code template.



2. If you create and edit various templates:

Syntax for defining code templates: Template <Template Name>, <field> [= default value] <field> ......
Template Composition Element: Template Name, parameter name, and default value of the parameter. The default value of the parameter can be omitted.
Format symbols: (>), quotation marks (""), commas (,), (&), and space characters.
When defining a Template Name, use the (>) format to organize the multi-level template sub-menu structure.
Template Name. The parameter name and default value are defined in the quotation marks (""). If you use a single letter (separated by a space character), you can omit the quotation marks ("") this parameter is required only when the Template Name, parameter name, and parameter default value contain space characters.
Parameter and Template Name. Each parameter is defined by comma.
Use (&) to define the last 1st ASCII characters as the shortcut key <letter>, which can be defined in any location of the Template Name and parameter name.


(1) create a simple piece of code

Take if... else as an example. The template code is:

#TEMPLATE "&Statement>&if...else"if( %c ){}else if{}
Statement is defined by itself, similar to the group name.
If... else is the Template Name

% C is the position where the cursor stays after the template is inserted.

The following is the switch... case template.

#TEMPLATE "&Statement>&switch"switch( %c ){case 0:    break;default:    break;}


(2) templates that require parameter input

Take the for loop template as an example:

#TEMPLATE &Statement>&for,"&End Value"=10,&Variable=ifor(int %2 = 0; %2 < %1; ++%2){  %c}

"" Is required only when the Template Name, parameter name, and default value of the parameter contain a space character.

% 2 indicates that the second parameter in the reference definition is


Function template:

#TEMPLATE &Function>&Function,"Function &name","Input &parameter","Return &parameter",&Description=--,&Created="$DATE$, by HuangZhiGang"/******************************************************************************** Function     : %1()* Input        : %2* Return       : %3* Description  : %4** Author       : %5*******************************************************************************/void %1(void){%c}




IAR template-how to create and use a template in the IAR Project

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.