DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Shell Scripting (http://www.daniweb.com/forums/forum113.html)
-   -   Change standard include path (http://www.daniweb.com/forums/thread199147.html)

rajenpandit Jun 23rd, 2009 12:50 am
Change standard include path
 
Hi everybody, I have a problem in include path. i want to keep my all header file in folder named myInclude and include it like #include<myInclude/header.h>, Is there any possible way to do this, if there is than please tell me the step.
thanks in advance...........

msvinaykumar Jun 25th, 2009 1:59 pm
Re: Change standard include path
 
Use unix profile file

eggi Jun 28th, 2009 2:23 am
Re: Change standard include path
 
Hey there,

If you're doing this for C, you can just use quotes instead of the angle brackets, like

#include "/home/yourdir/myInclude/header.sh"

If you're using a shell and your includes are functions, you can put them in your .profile, as advised above or just create your header.sh file and source it at the head of all of your script like:

#!/bin/bash

. /home/yourdir/myIncludes/header.sh

code
code
code

and you'll be all set :)

, Mike

Salem Jun 28th, 2009 3:54 am
Re: Change standard include path
 
> #include "/home/yourdir/myInclude/header.sh"
Don't do this.
Absolute paths to header files are a disaster waiting to happen.
If you reorganise your workspace, or give the code to someone else, then you have to edit ALL the code just to make it compile again.

Instead, do
gcc -I/home/yourdir prog.c

where /home/yourdir is the place where the myInclude directory exists, containing the header.h file.

rajenpandit Jul 6th, 2009 1:27 pm
Re: Change standard include path
 
Thank u salem. its working...........


All times are GMT -4. The time now is 1:11 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC