I'm having to use Eclipse for an existing C project that I am adding to and modding and I cannot work out how to set up include paths so I don't have to do things like this:
#include "../other_folder/foo.h"
I have gone into:
Project Properties | C/C++ General | Paths And Symbols
And selected Includes Tab.
Then selected GNU C for the language and then added relative paths. So, for example, added /other_folder into the list of include paths.
However, I still have to put the relative path in for the headers in the source code.
Am I asking for something Eclipse just can't do in expecting to be able to add these paths and be able to do:
#include "foo.h"
rather than
#include "../other_folder/foo.h"
In any source file?
I've even tried putting absolute paths in the project includes, rather than relative paths, but that doesn't work either. What is even weirder is Eclipse gives a message that relative paths are ambiguous!
I have seen this:
Eclipse can't find header file, even though include paths are set
But his solution isn't relevant to this, that wrench thing doesn't show for me. I've trawled through other similar posts, but can't find anything in them that points to what I'm doing wrong.
An example of an output from the compiler if I don't put the path in the source code for a specific issues is this:
Info: Compiling Registers/registers.c to obj/default/Registers/registers.o
nios2-elf-gcc -xc -MP -MMD -c -I../USB3_Controller_BSP//HAL/inc -I../USB3_Controller_BSP/ -I../USB3_Controller_BSP//drivers/inc -pipe -D__hal__ -DALT_NO_INSTRUCTION_EMULATION -DALT_USE_SMALL_DRIVERS -DSMALL_C_LIB -DALT_SINGLE_THREADED -O -g -Wall -mno-hw-div -mhw-mul -mhw-mulx -mgpopt=global -o obj/default/Registers/registers.o Registers/registers.c
Registers/registers.c:2:22: fatal error: pc_comms.h: No such file or directory
I think the -I is the include paths which does suggest it's just not seeing the include paths I have added. Not sure about the double forward slashes either. eg:
/USB3_Controller_BSP//drivers/inc
That seems odd.
On top of all this, if i delete all entries from the include paths, it keeps telling me there's a whole host of invalid paths such as:
Description Resource Path Location Type
Invalid project path: Include path not found (/home/me/Software/company/USB_Controller_Software/software/USB3_Controller/USB3_Controller/comms). USB3_Controller pathentry Path Entry Problem
Anyone have any suggestions as to what I'm doing wrong please? I suspect I'm missing something fundamental here in the way Eclipse sets up include paths.
(Please don't have a go about the mixed styles of directory naming and file naming, this is not of my doing!)
FWIW Using Mars.2 on Linux for NIOS.