[Preprocessor] Relative Addresses in BOOST_PP_FILENAME_1
Dear all, I am trying to use BOOST_PP_FILENAME_1 for a header file in my current directory. Unless I hardcode the full address, GCC 4.5.1 (MinGW32, WinXP, SP3) says it can't find the same file in which I am using BOOST_PP_FILENAME_1! Is there any way I can go for relative file names? I have already checked the following -- neither works for the same reasons: #define BOOST_PP_FILENAME_1 "./Header.hpp" //1 #define BOOST_PP_FILENAME_1 ".\Header.hpp" //2 #define BOOST_PP_FILENAME_1 "Header.hpp" //3 TIA, --Hossein
2011/1/24 Hossein Haeri
Dear all,
I am trying to use BOOST_PP_FILENAME_1 for a header file in my current directory. Unless I hardcode the full address, GCC 4.5.1 (MinGW32, WinXP, SP3) says it can't find the same file in which I am using BOOST_PP_FILENAME_1! Is there any way I can go for relative file names? I have already checked the following -- neither works for the same reasons:
#define BOOST_PP_FILENAME_1 "./Header.hpp" //1
#define BOOST_PP_FILENAME_1 ".\Header.hpp" //2
#define BOOST_PP_FILENAME_1 "Header.hpp" //3
I have the same problem with you, I also use GCC 4.5.1, while <> works fine but "" not.
On 1/23/2011 1:27 PM, Hossein Haeri wrote:
Dear all,
I am trying to use BOOST_PP_FILENAME_1 for a header file in my current directory. Unless I hardcode the full address, GCC 4.5.1 (MinGW32, WinXP, SP3) says it can't find the same file in which I am using BOOST_PP_FILENAME_1! Is there any way I can go for relative file names? I have already checked the following -- neither works for the same reasons:
#define BOOST_PP_FILENAME_1 "./Header.hpp" //1
#define BOOST_PP_FILENAME_1 ".\Header.hpp" //2
#define BOOST_PP_FILENAME_1 "Header.hpp" //3
It is because BOOST_PP_FILENAME_1 expands in a Boost PP header file. In
GCC a relative file name is relative only to the file in which it is
included. Since it is a Boost PP header file that does the including,
your relative header file will not be found.
In VC++ on Windows relative header files are relative to an entire chain
of header files being included to that point from the source file on
down, so a relative header file as you have above would be found.
I ran into this same problem also and ended up just using a non-relative
name of the form
Hi Edward,
It is because BOOST_PP_FILENAME_1 expands in a Boost PP header file. In GCC a relative file name is relative only to the file in which it is included. Since it is a Boost PP header file that does the including, your relative header file will not be found.
In VC++ on Windows relative header files are relative to an entire chain of header files being included to that point from the source file on down, so a relative header file as you have above would be found.
Well, isn't this addressable in Boost PP? I mean, can Boost PP just not make its expansion compatible with this cross-compiler issue?
I ran into this same problem also and ended up just using a non-relative name of the form
for all compilers as the easiest solution.
But, this requires my clients to copy my stuff under their local Boost directory, right? TIA, --Hossein
AMDG On 1/23/2011 1:37 PM, Hossein Haeri wrote:
It is because BOOST_PP_FILENAME_1 expands in a Boost PP header file. In GCC a relative file name is relative only to the file in which it is included. Since it is a Boost PP header file that does the including, your relative header file will not be found.
In VC++ on Windows relative header files are relative to an entire chain of header files being included to that point from the source file on down, so a relative header file as you have above would be found.
Well, isn't this addressable in Boost PP?
No. Boost.PP can't change how the compiler searches for headers.
I mean, can Boost PP just not make its expansion compatible with this cross-compiler issue?
I ran into this same problem also and ended up just using a non-relative name of the form
for all compilers as the easiest solution. But, this requires my clients to copy my stuff under their local Boost directory, right?
No. That's just a specific example. You just need to make sure that the header is in the compiler's include path. In Christ, Steven Watanabe
Hi Steven,
Well, isn't this addressable in Boost PP?
No. Boost.PP can't change how the compiler searches for headers.
I obviously didn't mean this. See below please.
I mean, can Boost PP just not make its expansion compatible with this cross-compiler issue?
Like I have also said above, I am asking for Boost PP to adapt itself with this cross-platform issue. To put it differently, why is BOOST_PP_FILENAME_1 not portable? Can Boost PP please address that?
I ran into this same problem also and ended up just using a non-relative name of the form
for all compilers as the easiest solution. But, this requires my clients to copy my stuff under their local Boost directory, right?
No. That's just a specific example. You just need to make sure that the header is in the compiler's include path.
Sorry I'm quite puzzled with your words above.
From what I can read in the Section on Self Iteration under A.4.1.2 in:
http://www.boostpro.com/tmpbook/preprocessor.html
for Self Iteration, the file passed to BOOST_PP_FILENAME_1 needs to be the same file that I'm using BOOST_PP_FILENAME_1 in.
Let's say that I'm using BOOST_PP_FILENAME_1 in Header.hpp. From what I understand of the above link, I should have the following line at the appropriate part of my Header.hpp to get Self Iteration:
#define BOOST_PP_FILENAME_1 "Header.hpp"
Now, are you telling me that I can replace the above line with, say, the following?
#define BOOST_PP_FILENAME_1
AMDG On 1/24/2011 10:38 AM, Hossein Haeri wrote:
Well, isn't this addressable in Boost PP?
No. Boost.PP can't change how the compiler searches for headers.
I obviously didn't mean this. See below please.
I mean, can Boost PP just not make its expansion compatible with this cross-compiler issue?
Like I have also said above, I am asking for Boost PP to adapt itself with this cross-platform issue. To put it differently, why is BOOST_PP_FILENAME_1 not portable? Can Boost PP please address that?
Adapt? How? All that Boost.Preprocessor does is #include BOOST_PP_FILENAME_1. There's nothing else it /can/ do. In Christ, Steven Watanabe
participants (4)
-
Edward Diener
-
Hossein Haeri
-
Steven Watanabe
-
TONGARI