include ,h files from dir inside dir
Hi all,
hope this makes sense, it's hard to put into words. Basically I have a dir that contains my makefile and another directory inside this called source this holds main source files. External to these I have a couple of dirs common and drives. In my make file I use DINCDIR = -I../Drivers -I../CommonFiles to include the protoypes from the headers in the folders common and drivers used by source, this works fine. However in common and drivers I use a few variables that are set in the source dir. I set these with externs inside the common and driver files. However I'm sure I should be able to set the directory path for source inside my makefile. So say I have inside source hardware.h with prototypes, I set DINCDIR = -I/Source -I../Drivers -I../CommonFiles Then from a c file inside my common folder I say #include "hardware.h" the file should be able to see hardware.h and it's protoypes. However I get error: Hardware_Config.h: No such file or directory error: ‘Button_1’ was not declared in this scope ect. Is there some way I can get the extern dirs to see the source dir? The set out is something like level 1 common dir driver dir level 2 main dir cointains makefile level 3 source dir source files Thanks in advance, this is simple to see but hard to put into word :s |
Quote:
If I understood you correctly, you have external components (drivers and common) that are "reaching" into your source code for access to global variables. It is normal for a project to reference external libraries (e.g. libc or your library), but for a library to depend on a project is blasphemous. You need to consider re-factoring your code, rather than to come up with a hokey solution. I strongly suggest that you dispense with the global variables, and instead consider declaring local variables that can be passed as parameters to functions that you call. If a function needs the value of a variable, then it should call a "getter" function that provides the value. As for the rest of your code, it is hard to speculate what you have. But from what you posted, the common code does not seem so "common". |
All times are GMT -5. The time now is 09:26 PM. |