Project versus per-file properties
In most cases, the properties for the files being built as part of a project are controlled at the project level (with one set of properties being maintained per Build Configuration - Debug and Release).
Thus when you open the properties by opening the menu "Project -> Properties", you will see that the title bar of the Properties window will say "Properties for <projectname>"
However there are some circumstances where you might want a finer granuality of control. For example, you might want most of your application code built at -O2 (to provide good performance, but still with some attention paid to code size), but for a few performance critical files to be built at -O3.
In order to allow this, the Eclipse IDE also allows you to modify properties at a per-file level. To do this, right click on the file in the Project Explorer view to display the context sensitive menu and then select "Properties" from (or simply select the file and press alt-enter).
The title bar of the Properties window that will now appear will say "Properties for <filename>" and will also display a reduced range of options compared to the Project Properties Window (for a .c file, it will only show the tool settings for the MCU C Compiler).
You can now modify the properties for this file (remembering if necessary to modify for both Debug and Release Build Configurations).
After carrying out the required modifications and clicking OK, if you look at the icon for the file in the Project Explorer, this will change slightly to indicate that a per-file properties change has been made (known as "label decoration") - the icon will have "<>" at the top of it, as per the below screenshot:
(Note that you may need to select refresh - or press F5 - for this icon change to appear).
If, after modifying the properties of the file, you decide you want to remove those modifications, the easiest way to do so is select the file, go to the file properties and click on "Restore defaults".
It is also possible to modify the properties for a whole subdirectory of files at once. To do this right click on the subdirectory in the Project Explorer view and select "Properties" from the context sensitive menu (or select the subdirectory and press alt-enter).
The title bar of the Properties window that will now appear will say "Properties for <directory_name>" and will also display a reduced range of options (depending on what file types are contained within the subdirectory).
Again, after editing the properties, the icon for the subdirectory in the Project Explorer view will update to have "<>" at the top of it, so as to indicate per-directory properties have been set.
Using Per-file and per-directory properties
Although being able to modify the properties of particular files or directories provides a great deal of flexibility, it can also cause problems if care is not taken. This can particularly be the case if you forget that properties have been changed in this way, or if you pass your project to someone else.
For this reason, it is advisable to ensure that the project contains documentation that details any per-file or per-directory property changes that have been made (and why). One way of working is to only make changes at the directory level, and give such directories names that indicate property changes have been made.
For example, say you start off with one directory containing all your sources, called "src". You then decide you have one or two files that you wish to compile at -O3 rather than -Os in the Release Build configuration. You could create a new source directory with the appropriate property changed called "src_rel_O3" and place the files to be compiled at -O3 in there.
Warning about per-directory properties
If you use per-directory properties in your project, always do a test build to check in the build console that the properties you have set are actually getting picked up, as it appears that the Eclipse CDT build engine that sits underneath the Code Red IDE sometimes fails to use properties set at the per-directory level.
The safest way to use per-directory properties is to create a new source folder in the root of your project, say src_per-dir-properties and set the required properties on this directory. It appears that if you place a subdirectory directly in the standard src directory, then any properties set on this subdirectory may not get picked up. But if you create a further level of subdirectory within this, then per-directory properties do appear to get picked up.