473,796 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2564
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*****@ifranc e.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.c om/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
27823
by: s | last post by:
Can I do this: #define MYSTRING "ABC" .. .. .. char mychar = MYSTRING; .. .. ..
5
2403
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( size_t size ); void *operator new( size_t size, AllocationType allocType ); void *operator new( size_t size, MemoryHandler* memHandler ); void *operator new( size_t size, MemoryHandler* memHandler, AllocationType
18
8930
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 to create multiple functions which they look almost identical in C++ source code. The C++ compiler should be able to compile one Test() function into two almost identical functions before they are translated into the machine language object. ...
2
4520
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 #define statements that associate GUIDs wih a friendly name. For e.g. consider the file zoo.h: ....
2
5594
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, but I don't understand where cam_morphomaths_code.c is included and how to set what parameters to use in the testbench. How does this code execure? I don't understand a bit...
2
12832
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
3098
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 another include it's 0x0). I cannot change contents of those two includes. This generates comipler warning 'macro redefined'. It's easy to suppress the warning with #ifdef. But I want to also cross-check that those two macros have same value. I am...
71
33238
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 (TRUE) #define TRUE (1)
6
27902
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
3234
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 #define with const. example: 2 header file StringGrid1.h StringGrid2.h
0
9679
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10453
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.