The RobotC compiler needs to know where to look for includes. In a full compiler there are a number of predefined directories, usually a subdirectory of the compiler's main directory, where it looks for common includes accessed like this:
IDEs with integrated compilers will usually create a special project directory and include those paths as well in the search. RobotC which is far simplier than high end IDEs doesn't set up a special directory for projects but you can specify a directory to search for custom includes. Under the View menu select "Preferences"; then select the "Directories" tab and in the "Directory for Source Files" type the directory where you are keeping your source files. Remember that if this is a place like My Documents you must enter "
Windows Drive (usually C:)\Documents and Settings\
User name\My Documents\..." or for the less technically inclinded use the "Browse" button to find your directory.
You can then reference your headers or includes thusly:
You can also include another file from an include, like so:
Just keep in mind when putting functions in includes that the function must be defined prior to its usage. If you use a function in "header 1.h" or "header 2.h" you can use it in "header 3.h" but a function declared in "header 3.h" may not be used in the other two files.
Also keep in mind that you must not include the same header more than once. So in the above example you could not put a #include for "include 2.h" in "include 3.h".
Additionally you can not have circular includes,
Separating your code into spearate files can be an extremely useful tool, espicially if you have a large amount of code. If you have functions that you might use over and over or that can be used from year to year putting those in an header file that can be accessed in later programs will save you time and bulk in your main program. As long as you are wary of the rules of includes then you should be fine. Keep in mind also the fact that includes add a layer of complexity to your code and thus you run the risk of creating more errors; use them only if you are comfortable coding as well as debuging.
Hope this helps and good luck with your ventures with "ROBOTC".
