Open utterances-bot opened 11 months ago
Important!: if you bring in a project to Eclipse by going to File --> Open Projects From Filesystem..., instead of File --> New --> C/C++ Project, you may not have the "Paths and Symbols" option at all under right-click-on-project --> Properties –> C/C++ General –> Paths and Symbols!
Ex: on mbed-os,
instead of seeing this in the project "Properties" menu:
you may see this (notice that C/C++ General –> "Paths and Symbols" is missing!):
If that happens, first, delete the project from Eclipse: right-click it --> Delete --> ensure "Delete project contents on disk" is not selected --> click "OK".
Then, wipe all changes in the git project via the terminal as follows:
# WARNING: THE FOLLOWING WILL PERMANENTLY DELETE ANY UNCOMMITTED CHANGES
# delete all changes to tracked files
git reset --hard
# see what will be deleted if I want to delete all untracked, but not `.gitignore`d, files too
git clean -dn
# then delete them
git clean -df
# see what will be deleted if I want to delete all files & dirs ignored by the .gitignore files
git clean -Xdn
# then delete them
git clean -Xdf
# This file should have been removed by one of the `git clean` commands above,
# depending on whether or not your repo has Eclipse `.cproject` files in the
# `.gitignore` file, but let's just run these commands to be double-sure the
# old Eclipse project files are deleted first, as if they are not, it will
# cause the next step to NOT work right when you recreate the project and then
# try to add your custom macro definitions!
rm .cproject
# and, just to be safe, delete the other Eclipse project files that may exist too; this is
# the total command necessary to delete all Eclipse project files in the repo root
rm -rf .cproject .project .pydevproject .settings
Ex: here's how I add the mbed-os project for indexing and editing in Eclipse:
File --> New --> C/C++ Project --> C++ Managed Build --> "Next >" --> uncheck the "use default location" box, click "Browse..." and navigate to the mbed-os folder and choose "Open". Then, type in mbed-os
into the "Project name" box. You'll now see this:
To finish, click "Next" repeatedly until it lets you click "Finish", and then click "Finish".
If a box pops up with a title that says, "Old project will be overridden", click "OK".
If you right-click the project and go to Properties, you'll now see "Paths and Symbols" under "C/C++ General", as shown in the first screenshot above. You can then continue my tutorial as described in the article.
Note: even though my steps above to define custom macros do work in most projects/repos to make the indexer index according to those defined macros, the mbed-os repo doesn't seem to work. Others do (I just checked), but not that one. I don't know why. My test was to define a GSTEST
macro in the project settings, and then test it in the code like this to see if this section is black (showing it as not defined), or normal-colored (showing it as defined):
#ifdef GSTEST
#endif
...and the result is that the Eclipse indexer in the mbed-os repo only, does not see this macro as defined. Yet, the macro definition is in the Eclipse .cproject
file too, so I don't know what's going on in this particular case.
Like I said, though, I ran the test above in other repos too and it works fine, with GSTEST
getting properly defined and seen by the Eclipse indexer.
Possibly it's because mbed-os already has some other Eclipse project definition files in it?
I did a search for .cproject
...
Update: fixed! I needed to forcefully delete the old and wrong Eclipse .cproject
too, which was left over from the wrong version I had created and referred to in my previous comment above.
So, after running git clean -Xdf
or rm .cproject
in the mbed-os
repo root, and then recreating the Eclipse project per my instructions above, everything worked just fine! I updated my instructions above to add the git clean -Xdf
step too, and some rm
commands to be extra thorough to be sure you've deleted all old and wrong Eclipse project files before re-creating the Eclipse project again the right way.
How to define macros for the Eclipse builder and indexer so it indexes your code correctly | GabrielStaples.com
Problem: Eclipse won’t index my project correctly, and parts of it are blacked out!
https://gabrielstaples.com/eclipse-defining-custom-macros-for-indexer/