I have a bunch of conditional #include statements like
#if PLATFORM == "LINUX"
#include "LinuxImplementation.h"
#elif PLATFORM ==" WINDOWS"
#include "WindowsImplementation.h"
#elif PLATFORM ==" MACINTOSH"
#include "MacintoshImplementation.h"
#endif
Is there some way I can use the standard preprocessor functionality to
transform this into a single #include stmt like
#include <PLATFORM "Implementation.h">
where 'PLATFORM' gets concatenated in front of "Implementation.h"?
My experiments with Microsoft's VC7 preprocessor have not been
successful so far.
Thanks! 13 2634
James wrote: I have a bunch of conditional #include statements like
#if PLATFORM == "LINUX" #include "LinuxImplementation.h" #elif PLATFORM ==" WINDOWS" #include "WindowsImplementation.h" #elif PLATFORM ==" MACINTOSH" #include "MacintoshImplementation.h" #endif
Is there some way I can use the standard preprocessor functionality to transform this into a single #include stmt like
#include <PLATFORM "Implementation.h">
where 'PLATFORM' gets concatenated in front of "Implementation.h"?
My experiments with Microsoft's VC7 preprocessor have not been successful so far.
Provide a command-line macro that would be different on different
platforms similar to
-DPLATFORMIMPL2INCLUDE="\"LinuxImplementation.h\""
on Linux and
-DPLATFORMIMPL2INCLUDE="\"WindowsImplementation.h\" "
on Windows (and so on), and then do
#include PLATFORMIMPL2INCLUDE
in your code.
V
--
Please remove capital As from my address when replying by mail
Victor Bazarov wrote: James wrote: I have a bunch of conditional #include statements like
#if PLATFORM == "LINUX" #include "LinuxImplementation.h" #elif PLATFORM ==" WINDOWS" #include "WindowsImplementation.h" #elif PLATFORM ==" MACINTOSH" #include "MacintoshImplementation.h" #endif
Is there some way I can use the standard preprocessor functionality to transform this into a single #include stmt like
#include <PLATFORM "Implementation.h">
where 'PLATFORM' gets concatenated in front of "Implementation.h"?
My experiments with Microsoft's VC7 preprocessor have not been successful so far.
Provide a command-line macro that would be different on different platforms similar to
-DPLATFORMIMPL2INCLUDE="\"LinuxImplementation.h\""
on Linux and
-DPLATFORMIMPL2INCLUDE="\"WindowsImplementation.h\" "
on Windows (and so on), and then do
#include PLATFORMIMPL2INCLUDE
Couldn't he do something like:
#define HEADER_FILE_NAME PLATFORM "Implementation.h"
#include HEADER_FILE_NAME
red floyd wrote: Victor Bazarov wrote: James wrote: I have a bunch of conditional #include statements like
#if PLATFORM == "LINUX" #include "LinuxImplementation.h" #elif PLATFORM ==" WINDOWS" #include "WindowsImplementation.h" #elif PLATFORM ==" MACINTOSH" #include "MacintoshImplementation.h" #endif
Is there some way I can use the standard preprocessor functionality to transform this into a single #include stmt like
#include <PLATFORM "Implementation.h">
where 'PLATFORM' gets concatenated in front of "Implementation.h"?
My experiments with Microsoft's VC7 preprocessor have not been successful so far.
Provide a command-line macro that would be different on different platforms similar to
-DPLATFORMIMPL2INCLUDE="\"LinuxImplementation.h\""
on Linux and
-DPLATFORMIMPL2INCLUDE="\"WindowsImplementation.h\" "
on Windows (and so on), and then do
#include PLATFORMIMPL2INCLUDE
Couldn't he do something like:
#define HEADER_FILE_NAME PLATFORM "Implementation.h" #include HEADER_FILE_NAME
I don't think so. But do try it, and if you succeed, let us know.
V
--
Please remove capital As from my address when replying by mail
Victor Bazarov wrote: red floyd wrote: Victor Bazarov wrote: James wrote: I have a bunch of conditional #include statements like
#if PLATFORM == "LINUX" #include "LinuxImplementation.h" #elif PLATFORM ==" WINDOWS" #include "WindowsImplementation.h" #elif PLATFORM ==" MACINTOSH" #include "MacintoshImplementation.h" #endif
Is there some way I can use the standard preprocessor functionality to transform this into a single #include stmt like
#include <PLATFORM "Implementation.h">
where 'PLATFORM' gets concatenated in front of "Implementation.h"?
My experiments with Microsoft's VC7 preprocessor have not been successful so far. Provide a command-line macro that would be different on different platforms similar to
-DPLATFORMIMPL2INCLUDE="\"LinuxImplementation.h\""
on Linux and
-DPLATFORMIMPL2INCLUDE="\"WindowsImplementation.h\" "
on Windows (and so on), and then do
#include PLATFORMIMPL2INCLUDE Couldn't he do something like:
#define HEADER_FILE_NAME PLATFORM "Implementation.h" #include HEADER_FILE_NAME
I don't think so. But do try it, and if you succeed, let us know.
V
Doh! You're right. I was thinking of the automatic concatenation of
strings by the compiler. Naturally the preprocessor would barf.
However, there may still be a way... If the OP isn't permanently in
love with having his PLATFORM in quotes.... e.g. instead of
#if PLATFORM=="Linux"
use
#if PLATFORM==Linux
Then can't we do something like the following?
DISCLAIMER: my memory of preprocessor quoting/evaluation is flaky.
#define str_(x) #x
#define str2_(x) str(x)
#define cat2_(x,y) x ## y
#define cat_(x,y) cat2(x,y)
#define PLATFORM_STRING str2_(PLATFORM)
#define HEADER_FILE str2_(cat2(PLATFORM, Implementation.h))
#include HEADER_FILE
"red floyd" <no*****@here.dude> wrote in message
news:k5*******************@newssvr11.news.prodigy. com... However, there may still be a way... If the OP isn't permanently in love with having his PLATFORM in quotes.... e.g. instead of
#if PLATFORM=="Linux"
use
#if PLATFORM==Linux
Then can't we do something like the following?
DISCLAIMER: my memory of preprocessor quoting/evaluation is flaky.
#define str_(x) #x #define str2_(x) str(x) #define cat2_(x,y) x ## y #define cat_(x,y) cat2(x,y)
#define PLATFORM_STRING str2_(PLATFORM) #define HEADER_FILE str2_(cat2(PLATFORM, Implementation.h)) #include HEADER_FILE
No. Part of how the preprocessor locates include files depends on how they
are included; that is, whether they are included as:
#include "somefile.h"
or
#include <somefile.h>
Your method will not work because it provides neither quotes nor brackets
(and as already stated, the preprocessor does not treat string-literals the
same way the compiler does).
- Dennis
"Dennis Jones" <no****@nospam.com> wrote in message
news:AVbag.5375$Sh3.690@trnddc05...
No. Part of how the preprocessor locates include files depends on how
they are included; that is, whether they are included as:
Actually, much to my surprise, after some investigation and several typo
corrections, your method does indeed work:
#define str_(x) #x
#define str2_(x) str_(x)
#define cat_(x,y) x ## y
#define cat2_(x,y) cat_(x,y)
#define PLATFORM Windows
#define HEADER_FILE str2_(cat2_(PLATFORM, Implementation.h))
#include HEADER_FILE
Which results in:
Borland C++ Win32 Preprocessor 5.6.4 Copyright (c) 1993, 2002 Borland
file1.cpp:
Error E2209 file1.cpp 8: Unable to open include file
'WindowsImplementation.h'
*** 1 errors in Compile ***
- Dennis
Dennis Jones wrote: "Dennis Jones" <no****@nospam.com> wrote in message news:AVbag.5375$Sh3.690@trnddc05...
No. Part of how the preprocessor locates include files depends on how they are included; that is, whether they are included as:
Actually, much to my surprise, after some investigation and several typo corrections, your method does indeed work:
#define str_(x) #x #define str2_(x) str_(x) #define cat_(x,y) x ## y #define cat2_(x,y) cat_(x,y)
#define PLATFORM Windows #define HEADER_FILE str2_(cat2_(PLATFORM, Implementation.h)) #include HEADER_FILE
Which results in:
Borland C++ Win32 Preprocessor 5.6.4 Copyright (c) 1993, 2002 Borland file1.cpp: Error E2209 file1.cpp 8: Unable to open include file 'WindowsImplementation.h' *** 1 errors in Compile ***
Remember, the unary # operator is the string-izer.
"red floyd" <no*****@here.dude> wrote in message
news:0C*******************@newssvr29.news.prodigy. net... Dennis Jones wrote: Actually, much to my surprise, after some investigation and several typo corrections, your method does indeed work:
Remember, the unary # operator is the string-izer.
I know that -- I just didn't think about quotes being inserted implicitly.
Thus, I suppose if the OP wanted:
#include < ... >
....he'd be up a creek.
- Dennis
Dennis Jones wrote: "red floyd" <no*****@here.dude> wrote in message news:0C*******************@newssvr29.news.prodigy. net... Dennis Jones wrote:
Actually, much to my surprise, after some investigation and several typo corrections, your method does indeed work: Remember, the unary # operator is the string-izer.
I know that -- I just didn't think about quotes being inserted implicitly. Thus, I suppose if the OP wanted:
#include < ... >
...he'd be up a creek.
- Dennis
Disclaimer: I haven't tested this. And it may not work.
#define STD_INCLUDE(x) cat2_(cat2_(<,x),Implementation.h>)
#include STD_INCLUDE(PLATFORM)
red floyd wrote: Disclaimer: I haven't tested this. And it may not work.
#define STD_INCLUDE(x) cat2_(cat2_(<,x),Implementation.h>)
#include STD_INCLUDE(PLATFORM)
This will error because the result of token-pasting must be a single token. In
any case, it doesn't matter because if a file is not found via the "file"
syntax, it is re-looked up as if it used the <file> syntax. This is required by
the standard. The reverse, however, is not the case.
Regards,
Paul Mensonides
Paul Mensonides wrote: This will error because the result of token-pasting must be a single token.
This lovely hack might still work:
#define cat2_(a,b) a\
b
One wonders how legal it is... ;-)
--
Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
"James" <du****@hotmail.com> skrev i meddelandet
news:11*********************@y43g2000cwc.googlegro ups.com... I have a bunch of conditional #include statements like
#if PLATFORM == "LINUX" #include "LinuxImplementation.h" #elif PLATFORM ==" WINDOWS" #include "WindowsImplementation.h" #elif PLATFORM ==" MACINTOSH" #include "MacintoshImplementation.h" #endif
Is there some way I can use the standard preprocessor functionality to transform this into a single #include stmt like
#include <PLATFORM "Implementation.h">
where 'PLATFORM' gets concatenated in front of "Implementation.h"?
My experiments with Microsoft's VC7 preprocessor have not been successful so far. Thanks!
What about using literally #include "platform/implementation.h", and
supply a different 'platform' directory for each configuration?
Bo Persson
Phlip wrote: Paul Mensonides wrote:
This will error because the result of token-pasting must be a single token.
This lovely hack might still work:
#define cat2_(a,b) a\ b
One wonders how legal it is... ;-)
It isn't. Or rather, it's legal but it won't do what you want. The result of
the should be 'ab' in all cases.
cat2_(1, 2) -> ab
Unfortunately, not all preprocessors implement the phases of translation as they
should.
Regards,
Paul Mensonides This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mo |
last post by:
Hi all,
I hope that someone out there can help me with a problem I have been having.
I have just finished creating a website and have added a header to most of
the pages on my site. The header...
|
by: Chad Scharf |
last post by:
I have a legacy ASP application running on IIS 6.0 (Windows Server 2003 Web
Edition) that is throwing an error when processesing a certain asp page that
has about 200 or so include directives.
...
|
by: Ramesh |
last post by:
Hi,
I am currently maintaining a legacy code with a very very large code base.
I am facing problems with C/C++ files having a lot of un-necessary #includes.
On an average every C/C++ file has...
|
by: bill |
last post by:
Forget the exact definition of difference between,
#include <foo.h>
and
#include "bar.h"
Normally foo.h is a standard header file, so it's path is not defined
in compiler option, but I...
|
by: darrel |
last post by:
I'm trying to load an include dynamically. So, I'm writing out the include
tag via a response.write:
response.write("<!--#include virtual='" & contentIncludeFile &"' -->")
however, that's...
|
by: Jon Rea |
last post by:
I am currently cleaning up an application which was origainlly hashed
together with speed of coding in mind and therefore contains quite a few
"hacky" shortcuts.
As part of this "revamping"...
|
by: The Cool Giraffe |
last post by:
One thing i do know for sure. When one creates a CPP file,
one needs to include the H file. Now, having said that, i
wonder if there are some general hints, requirements or
standard guide lines on...
|
by: python |
last post by:
I'm parsing a text file for a proprietary product that has the following
2 directives:
#include <somefile>
#define <name<value>
Defined constants are referenced via <#name#syntax.
I'm...
|
by: thomas |
last post by:
priority_queue usually uses the greater<intpredicate function.
But as you know, we don't always use priority_queue<int>. Actually we
may need the "priority_queue<pair<int,int>,...
|
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
|
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...
|
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...
|
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...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
|
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...
| |