- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Any way to do token pasting in #include directive?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2005 02:57 AM
05-04-2005 02:57 AM
I'm trying to create a unit test driver that can include a particular unit, and a particular unit test, as in:
// driver.c
#include "unit.c"
// library functions
#include "test_unit.c"
---
except that I want unit.c and test_unit.c to be parameterized. I've tried all sorts of things, but it looks like the "no recursive macro expansion" is going to kill the idea.
I've tried the following:
// driver.c
#include foo
--
cc /define="foo=unit.c" driver.c
and that doesn't work.
The following DOES work:
// driver.c
#define foo "unit.c"
#include foo
My problem is that, for the life of me, I can't figure out how to get the double quotes to surround the file name.
I'm trying to build a .COM file that can compile a particular unit. Please forgive the following pseudo-code- I haven't used VMS for 20 years, so I have to relearn DCL.
$ unit=fn_foo
$ un_inc="unit_"+$unit+".h"
$ un_src=$unit+".c"
$ un_drv="driver_"+$unit+".h"
$ cc /define="hdr=$uninc,code=$un_src,driver=$un_drv"
driver.c
Something. ANYTHING. But that above example still won't get the double-quotes into the defined string.
That's what's really driving me crazy. I can't use any kind of token pasting or other manipulation that the compiler will accept to turn foo.c into "foo.c" within a #include statement.
I've searched the forums, (I think. I hope) and I didn't find anything on "token pasting".
Is there another solution? Is there a simple way to embed a double quote character in a /define="stuff" statement?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2005 03:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2005 03:38 AM
05-04-2005 03:38 AM
Re: Any way to do token pasting in #include directive?
$ DEFINE FOO "UNIT.C"
I don't know if the C compiler will do the right thing.
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2005 03:38 AM
05-04-2005 03:38 AM
Re: Any way to do token pasting in #include directive?
As usual in DCL: quote the quotes.
Example:
cc/define=(FOO="""XXX.H""") sys$input
#include FOO
Will include file XXX.H .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2005 04:45 AM
05-04-2005 04:45 AM
Re: Any way to do token pasting in #include directive?
The one technique that worked for me:
cc /define="foo=""unit.c""" driver.c
All the ones using $ define foo unit.c didn't work, although admittedly this was on the command line, and not in a .com file.
The fact that I'm still in this thread is my own fault. I need to define more than one string.
I've tried:
cc /define="foo=""unit.c"",bar=""unit.h""" driver.c
I get complaints about extra characters.
I've tried
cc /define=(foo=""unit.c"",bar=""unit.h"") driver.c
I get complaints about Unable to find unit as if the extension were being dropped.
I suppose this whole thing boils down to constructing strings and escaping quotes in DCL, but it just seems that there's no logical progression. The help says that for two defines, it should be:
/define="a=b,c=d" or something like that. But if you want quotes around b and d:
/define "a=""b"",c=""d""" it doesn't work.
In order to avoid messing up a second time by not supplying enough information, let me reiterate my goal: I want to be able to define "unit" as "fn_foo" and then build three strings around ''unit' and include three files whose names are constructed around ''unit', as shown in the original posting.
Much appreciation for sticking with me through this. I wish I knew why it wasn't possible to string multiple defines together in an obvious way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2005 04:56 AM
05-04-2005 04:56 AM
Re: Any way to do token pasting in #include directive?
cc /define=("foo=""unit.c""","bar=""unit.h""") driver.c
The rules for quotes are that two consecutive quotes inside a string will output a one quote in the string. The outer most quotes delimit the string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2005 04:59 AM
05-04-2005 04:59 AM
Re: Any way to do token pasting in #include directive?
For more than one use:
/define=("a=""b""","c=""d""")
Explanation:
First you must include the definitions in quotes because of DCL, which converts all unquoted strings in uppercase. So without quotes yyou realy receive:
/DEFINE=(A=....
Second when you want to put a single quote in a quoted string you substitute the quote with two quotes:
"a=""b""" becomes a="b"
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2005 05:00 AM
05-04-2005 05:00 AM
Re: Any way to do token pasting in #include directive?
Now to do the DCL to build the three file names from the one unit name.