Creating and working with header files is confusing for users
I tried to create a new header file. So I right-clicked on Application/User inside the Project Explorer view, and created a new header file. Little did I know, that the file would be created in the folder PROJECT_LOC/SW4STM32//Application/User. In result, the header file was not found by the compiler. I expected it to end up in the same folder as main.c, but it didn’t. Next I tried to right-click on the Inc folder (which is only visible after unfolding the “Includes” inside the project). But there’s no right-click-menu to create header files.
Then I started to realize that all the *.c files that I see inside the Project Explorer are linked resources. To make matters worse, the structure in the Project Explorer doesn’t match the structure in the filesystem. Anyhow, I created the header file on the command line in the PROJECT_LOC/Inc folder. And behold, I could include it, the compiler found it, and I could edit it from Eclipse.
Except: making changes to the header file wouldn’t trigger the CDT indexer. For example, after adding a define in the header file and using the define in main.c, Eclipse would complain that the symbol is not defined. Building the project would work fine, but Eclipse wouldn’t stop complaining until I rebuild the CDT index manually (right click on project, index->rebuild). Basically, I have to rebuild the index every time I add or remove defines.
I believe the reason for the latter is that the include files are not linked to the project. So the indexer somehow doesn’t consider them.
I believe all of the above issues could be resolved and the user experience could be much improved, if you would not link individual files, but if you would link whole folders. A list of folders to be linked would be
- PROJECT_LOC/../../Src
- PROJECT_LOC/../../Inc
- PROJECT_LOC/../../Drivers
- PROJECT_LOC/../../Middlewares
Right clicking on the linked Inc folder would allow users to create new header files without a hassle.
Right clicking on the linked Src folder would allow users to create new C files without a hassle (the same issue as described for headers also exists for C files).
Also, editing header files would probably update the CDT index without manual intervention.
However, I couldn’t test my last claim right now, as my project seems broken since I edited some Eclipse files by hand. Also, every time I generate code, CubeMX will overwrite the .project file. It will again link every individual file.
I’d like to strongly suggest that you reevaluate the decision to have linked files (instead of linked folders). It seems to have quite unpleasant implications that may confuse even experienced (Eclipse) users.
Things are complicated by the fact that the .project file is in fact generated by CubeMX. So the generator of CubeMX would have to be changed, I guess.