Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

CXX /INCLUDE qualifier

SOLVED
Go to solution
Ed Day
Advisor

CXX /INCLUDE qualifier

I am having a problem using the CXX /INCLUDE_DIRECTORY qualifier on OpenVms and I am wondering if I am doing something wrong. I set the directory to a parallel directory from where I am compiling as follows:

/INCLUDE="../rtsrc"

which is the way I do it on UNIX and it works fine. This works on OpenVms for direct includes (where the .cxx file includes a .h file) but does not seem to work for nested includes (where a .h file includes another .h file). Has anyone else encountered this problem or know a way to solve it?

Thanks,

Ed Day
8 REPLIES
John Gillings
Honored Contributor

Re: CXX /INCLUDE qualifier

The rules for INCLUDE file searching are complex and affected by numerous factors. See HELP CXX/INCLUDE_DIRECTORY or the C++ documentation for full details.

Note that in addition to /INCLUDE_DIRECTORY, the CXX command also has a qualifier /NESTED_INCLUDE_DIRECTORY which controls where the compiler looks for include files relative to the referencing file. Perhaps the default for this qualifier isn't what you want?

Experimenting with various combinations of qualifiers using Compaq C++ V6.5-004, I was able to make the compiler find nested include files where I wanted them fairly easily. Also note that the search logic is different depending on the syntax you use:

#include vs #include "a.h"
A crucible of informative mistakes
Antoniov.
Honored Contributor

Re: CXX /INCLUDE qualifier

Hi Ed,

I agree with John.
I compiled with a C (not C++) and thy have same qualifier. Try using /NESTED=PRIMARY.
If yet don't work use vms convention /INCL="[-.RTSRC]"

Bye
Antonio Maria Vigliotti
Ed Day
Advisor

Re: CXX /INCLUDE qualifier

Thanks for the answers, however, I am still not able to get it to work. I have the following compilation command line:

cxx /include="../rtsrc" /include="../rtbersrc" /nested=primary acGenEncode.cxx

(I also tried dir names in VMS form, both relative and absolute).

The file "acoptions.h" resides in the current working directory and includes "asn1type.h" which resides in the rtsrc directory. When I go to compile, I get the following:

#include "asn1type.h"
.....................^
%CXX-E-SRCFILNOOPEN, could not open source file "asn1type.h"
at line number 29 in file SPE51$DKA0:[ASN1C.ACSRC]ACOPTIONS.H;1

I am thinking the only option is to dump all the include files into a single directory which I hope is not the case.

Regards,

Ed
Martin P.J. Zinser
Honored Contributor

Re: CXX /INCLUDE qualifier

Well your example shows it all ;-), this is not
Unix ;->

Do not use separate /include options (the last one wins and is the only one active), but a list like /include=(dir1,dir2)
Antoniov.
Honored Contributor

Re: CXX /INCLUDE qualifier

Hi Ed,
Martin say correct.
With vms second /include overlap first so ../rtsrc is ignored.

Bye
Antonio Maria Vigliotti
Ed Day
Advisor

Re: CXX /INCLUDE qualifier

Thanks for the response.

I tried /include=("../rtsrc","../lmsrc") and it made no difference.

Copying all of the header files to my current working directory is working, so I guess I'll stick with doing it that way.

Thanks to all who answered.

Ed
John Gillings
Honored Contributor
Solution

Re: CXX /INCLUDE qualifier

Ed,

I'm not completely clear on where you want the nested include file to be read from. You should be able to find some combination of qualifiers that do whatever you want. Try this test:

main.cxx
#include
#include "a.h"

a.h
#include
#include "b.h"

b.h
// comment identifying the location

put appropriately commented copies of b.h in the current directory, the directory containing main.cxx and each of the include directories in the list. Then compile with
/LIST/SHOW=INCLUDE. Note that the location chosen depends on the format used. For example, with copies of B.H present in both source directory and the second include directory, and compiling with

$ CXX [.SRC]MAIN.LIS/LIST/SHOW=INCL-
/INCLUDE=([.INCL1].[.INCL2])/NEST=PRIMARY

my listing gives:

1 #include
I1 2 #include
I2 3 // [.INCL2]B.H
I1 4 #include "b.h"
I2 5 // [.SRC]B.H
6 #include "a.h"
I1 7 #include
I2 8 // [.INCL2]B.H
I1 9 #include "b.h"
I2 10 // [.SRC]B.H

Removing the file from the source directory and using the same command it changes to:

1 #include
I1 2 #include
I2 3 // [.INCL2]B.H
I1 4 #include "b.h"
I2 5 // [.INCL2]B.H
6 #include "a.h"
I1 7 #include
I2 8 // [.INCL2]B.H
I1 9 #include "b.h"
I2 10 // [.INCL2]B.H

The search path is defined in HELP CXX/INCLUDE. If you have an example that doesn't follow the rules, please try and characterise it with skeletal #include sources and report it to your local customer support centre.

A crucible of informative mistakes
Ed Day
Advisor

Re: CXX /INCLUDE qualifier

Hi John,

Upon closer inspection, I found putting all of the include directories in parens using a single /include statement worked. Thanks for all your help.

Regards,

Ed