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 examine 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 a few performance critical files be built at -O3.
The Eclipse IDE 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 to indicate that a per-file properties change has been made (known as "overlay decoration") - the icon will have "wrench" 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).
After modifying the properties of the file, if you then 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 optimization properties, the icon for the subdirectory in the Project Explorer view will update to have "wrench" 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.