Source Files

Source files containing source code should have the extension .c. The list of source files relevant to the application is stored in project file with extension .mcp32, along with other project information. You can compile source files only if they are part of the project.

Use the preprocessor directive #include to include header files with the extension .h. Do not rely on the preprocessor to include source files other than headers — see Add/Remove Files from Project for more information.

Managing Source Files

Creating new source file

To create a new source file, do the following:

  1. Select File › New Unit from the drop-down menu, or press Ctrl+N, or click the New File Icon New File Icon from the File Toolbar.
  2. A new tab will be opened. This is a new source file. Select File › Save from the drop-down menu, or press Ctrl+S, or click the Save File Icon Save File Icon from the File Toolbar and name it as you want.

If you use the New Project Wizard, an empty source file, named after the project with extension .c, will be created automatically. The mikroC PRO for PIC32 does not require you to have a source file named the same as the project, it’s just a matter of convenience.

Opening an existing file

  1. Select File › Open from the drop-down menu, or press Ctrl+O, or click the Open File Icon Open File Icon from the File Toolbar. In Open Dialog browse to the location of the file that you want to open, select it and click the Open button.
  2. The selected file is displayed in its own tab. If the selected file is already open, its current Editor tab will become active.

Printing an open file

  1. Make sure that the window containing the file that you want to print is the active window.
  2. Select File › Print from the drop-down menu, or press Ctrl+P.
  3. In the Print Preview Window, set a desired layout of the document and click the OK button. The file will be printed on the selected printer.

Saving file

  1. Make sure that the window containing the file that you want to save is the active window.
  2. Select File › Save from the drop-down menu, or press Ctrl+S, or click the Save File Icon Save File Icon from the File Toolbar.

Saving file under a different name

  1. Make sure that the window containing the file that you want to save is the active window.
  2. Select File › Save As from the drop-down menu. The New File Name dialog will be displayed.
  3. In the dialog, browse to the folder where you want to save the file.
  4. In the File Name field, modify the name of the file you want to save.
  5. Click the Save button.

Closing file

  1. Make sure that the tab containing the file that you want to close is the active tab.
  2. Select File › Close from the drop-down menu, or right click the tab of the file that you want to close and select Close option from the context menu.
  3. If the file has been changed since it was last saved, you will be prompted to save your changes.

Search Paths

You can specify your own custom search paths: select Project › Edit Search Paths... option from the drop-down menu :

Search Paths

Following options are available :
Icon Description
Add Search Path Add Search Path.
Remove Search Path Remove Search Path.
Purge Invalid Paths Purge Invalid Paths.

Paths for Source Files (.c)

You can specify either absolute or relative path to the source file. If you specify a relative path, mikroC PRO for PIC32 will look for the file in following locations, in this particular order:

  1. the project folder (folder which contains the project file .mcp32),
  2. your custom search paths,
  3. mikroC PRO for PIC32 installation folder > Uses folder.

Paths for Header Files (.h)

Header files are included by means of preprocessor directive #include. If you place an explicit path to the header file in preprocessor directive, only that location will be searched.

You can specify either absolute or relative path to the header. If you specify a relative path, mikroC PRO for PIC32 will look for the file in following locations, in this particular order:

  1. the project folder (folder which contains the project file .h),
  2. mikroC PRO for PIC32 installation folder > Include folder.
  3. your custom search paths
Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code