How to Add Folders and .c .h Files in IAR

IAR is a popular embedded development integrated environment. Below are the detailed steps to add folders and .c and .h files in IAR.

Add Folders

1. Open Workspace

Launch IAR Embedded Workbench and open the project workspace you want to operate on.

2. Expand Project View

In the IAR project browser on the left side, expand your project node, which usually has the same name as your project.

3. Create New Folder

Method 1: Use Menu Operation

Right-click on the project node or an existing folder node, and select “Add” -> “New Folder” from the pop-up menu. Enter the name of the new folder and press Enter to confirm.

Method 2: Use Shortcut Key

Select the project node or an existing folder node, and press the Insert key. This will pop up an input box for creating a new folder. Enter the folder name and press Enter.

Add .c and .h Files

Add Existing .c and .h Files

If you already have written .c and .h files and want to add them to the project, follow these steps:

1. Choose the Location to Add Files

In the project browser, select the folder node where you want to add the files (it can be the project root node or the new folder you just created).

2. Perform the Add Operation

Right-click on the selected folder node, and choose “Add” -> “Existing File…”. In the pop-up file selection dialog, find the .c or .h file you want to add. You can quickly locate the target file by setting the file type filter option to “C Source Files (.c)” or “Header Files (.h)”. Select the file to add and click the “Open” button, and the file will be added to the project.

Create New .c and .h Files

If you need to create new .c and .h files in the project, you can follow these steps:

1. Create New File

Select the folder node where you want to create the file, right-click on that node, and choose “Add” -> “New Item…”. In the pop-up “New Item” dialog, select the file type. If you want to create a .c file, select “C File”; if you want to create a .h file, select “Header File”. Enter the name of the new file and click the “Add” button.

2. Edit File Content

Once the new file is added to the project, it will open in the IAR editing area, and you can start writing code.

Configure Include Paths (for .h Files)

If the added .h files are located in a custom folder, you need to configure the project’s include paths so that the compiler can find these header files.

1. Open Project Options Dialog

Right-click on the project node and select “Options”.

2. Configure Include Paths

In the pop-up project options dialog, select “C/C++ Compiler” -> “Preprocessor”. In the “Additional include directories” text box, click the “…” button on the right, and then select the path of the folder containing the .h files. You can add multiple folder paths, separated by semicolons. Click “OK” to save the settings.

By following these steps, you can add folders and .c and .h files in IAR.

Leave a Comment