473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

define and include

mr
Hi

i try to do something like that:

#define PATH "mydir"

#include "PATH/myfile.h"

I would like to compiler to do :

#include "mydir/myfile.h"


But it doesn't work :)
And i can't find a way to make it work...

Is it a way?

thanks you very much
(Note: i don't want to just add the path to 'standard include path', i
really want to have it working the way i said above, if it's possible of
course :) )
Aug 2 '06 #1
4 2543
mr wrote:
Hi

i try to do something like that:

#define PATH "mydir"

#include "PATH/myfile.h"

I would like to compiler to do :

#include "mydir/myfile.h"


But it doesn't work :)
And i can't find a way to make it work...

Is it a way?
You can do something like:

#define FILE "mydir/myfile.h"
#include FILE

I don't know if concatenation of string literals works in #include
directives, like:

#define PATH "mydir"
#include PATH "/myfile.h"

Aug 2 '06 #2
You could do string concatenation in the preprocessor with ##.

But what you are asking cannot be done, since #include is
also a preprocessor command and the #include parameter
will not be changed by the preprocessor.

--
Papastefanos Serafeim

Ï "mr" <mr*****@ifrance.comÝãñáøå óôï ìÞíõìá
news:44***********************@news.free.fr...
Hi

i try to do something like that:

#define PATH "mydir"

#include "PATH/myfile.h"

I would like to compiler to do :
g
#include "mydir/myfile.h"


But it doesn't work :)
And i can't find a way to make it work...

Is it a way?

thanks you very much
(Note: i don't want to just add the path to 'standard include path', i
really want to have it working the way i said above, if it's possible of
course :) )


Aug 2 '06 #3

mr ha escrito:
Hi

i try to do something like that:

#define PATH "mydir"

#include "PATH/myfile.h"

I would like to compiler to do :

#include "mydir/myfile.h"


But it doesn't work :)
And i can't find a way to make it work...

Is it a way?

thanks you very much
(Note: i don't want to just add the path to 'standard include path', i
really want to have it working the way i said above, if it's possible of
course :) )
I think your compiler has a "add include directory" command. In gcc:
gcc -I/home/heltena/src/myIncludeDir module.c
( _i_, not L)

And, when I try to compile this:
#include <joseph.h>
int main() { return 0; }

The compiler looks for a "joseph.h" file in "/usr/include" (and others
standard directories) and then it tries
"/home/heltena/src/myIncludeDir".

bye!

Aug 2 '06 #4
Papastefanos Serafeim wrote:
You could do

See below.

Brian
--
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.htm>
Aug 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

97
by: s | last post by:
Can I do this: #define MYSTRING "ABC" .. .. .. char mychar = MYSTRING; .. .. ..
5
by: kUfa.scoopex | last post by:
Hi there! I have a small problem, and i really dont see any convenient way to fix it. Basically, i'd like to overload global new operators, into something like this: void *operator new(...
18
by: Bryan Parkoff | last post by:
"#define" can only be inside the global scope before main() function. "#if" can be tested after "#define" is executed. The problem is that "#define" can't be inside main() function. I do not wish...
2
by: psundara | last post by:
Hi, I'm facing a peculiar problem of finding a way to interpret header information in a smart way. I have this header file that is shared by many users, which contains, among things, a few...
2
by: Andreas | last post by:
Hi! I'm using an IplImage library from camellia.sourceforge.net, and the testbench calls a file only containing code like the one below. In cam_morphomaths_code.c the real computation is made,...
2
by: FBM | last post by:
Hi, I am preparing project for submission and i'd like to allow the print out of debug messages. I know that with something like #define DEBUG #ifdef DEBUG print(X); #endif
3
by: iler.ml | last post by:
I am writing code that uses two third-party libraries. They both define same macro OP_ENCRYPT, and luckily for me, they both define it to 0. (In one include, it's '#define OP_ENCRYPT 0', in...
71
by: David T. Ashley | last post by:
Where is the best place to define TRUE and FALSE? Are they in any of the standard include files, ever? Do any standards apply? What I've traditionally done is something like: #ifndef...
6
by: anirbid.banerjee | last post by:
Hi, I need to write a macro which would have a lot many conditional #ifdef ... #endif blocks in it. #define _xx_macro (x) { ... \ ... \ /* some code (); */ #ifdef _SOME_STMT \ ... \ ... \
5
by: MoslyChang | last post by:
Hi, All When I look at effective c++,item2 and item3. I have some basic questions , Does anyone be familar with this topic? it suggests const is perfer to #define, then I think how to replace...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.