Operating System - Tru64 Unix
1747985 Members
4899 Online
108756 Solutions
New Discussion юеВ

How to include header files in ProC/C++ programs?

 
P Satish
Advisor

How to include header files in ProC/C++ programs?

We have a header file by name defs.h and we want to include that in a ProC file test.pc
Both test.pc and defs.h are in same directory /usr/users/user1/ .

So, we have tried to include this header file in the test.pc as

"
#include

.....

"


It gives me an error saying, it could not open the file defs.h .
"PCC-S-02015, unable to open include file "

And any variable which is defined in test.pc results in an error in test.pc with unidentified identifier.
" PCC-S-02322, found undefined identifier"


But if we try to mention the full path in include directive it works. Like, if we say #include
.

Any suggestions are appreciated!
9 REPLIES 9
P Satish
Advisor

Re: How to include header files in ProC/C++ programs?

Correction:
"Any variable which is defined in defs.h, if used in test.pc , then it gives me PCC-S-02322, found undefined identifier"
Michael Schulte zur Sur
Honored Contributor

Re: How to include header files in ProC/C++ programs?

Hi,

the way you use include the compiler assumes the file to be in /usr/include.
You will have to use
#include "defs.h"

greetings,

Michael
P Satish
Advisor

Re: How to include header files in ProC/C++ programs?

defs.h is user defined header file for an application. It does not live under /usr/include. Let's say it lives off of /usr/users/user1 directory. How do I include this header file in the Pro C module /usr/users/user1/test.pc

I am trying to build the ProC module from /usr/users/user1 directory.

There was one include= option in ProC compiler, but it is not helping when I kept it as include=. for looking into the current directory for the header files.
Michael Schulte zur Sur
Honored Contributor

Re: How to include header files in ProC/C++ programs?

Hi,

when you use
#include
it is implicitely /usr/include/defs.h
the <> are resolved to /usr/include
If you want to use another path use the ""
#include "/usr/users/user1/defs.h"

greetings,

Michael
P Satish
Advisor

Re: How to include header files in ProC/C++ programs?

Thank you Michael for responding.

If I keep include "/usr/users/user1/defs.h" it works. But I need to use relative to the current directory as include "defs.h".
This is the requirement.
Michael Schulte zur Sur
Honored Contributor

Re: How to include header files in ProC/C++ programs?

Hi,

you said both files are in the same directory. So use
#include "defs.h"

hth,

Michael
P Satish
Advisor

Re: How to include header files in ProC/C++ programs?

When I do that, it gives me an error as I was mentioning before.
"PCC-S-02015, unable to open include file"
Michael Schulte zur Sur
Honored Contributor

Re: How to include header files in ProC/C++ programs?

Hi,

can you post the compilation script?
From which directory do you compile the programme?

thanks,

Michael
P Satish
Advisor

Re: How to include header files in ProC/C++ programs?

What do you mean by Compilation script?
I am using ProC options as below
"
proc include=. iname=../../../../src/unvantive/shared_lib_test/error_handler.pc oname=error_handler.c
"

$ make error_handler.c
cd ../../../obj/alpha/unvantive/shared_lib_test
proc include=. iname=../../../../src/unvantive/shared_lib_test/error_handler.pc
oname=error_handler.c

Pro*C/C++: Release 9.2.0.1.0 - Production on Mon Jan 10 23:09:03 2005

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

System default option values taken from: /oracle/app/oracle/product/9.2.0.1.0/pr
ecomp/admin/pcscfg.cfg

Error at line 8, column 10 in file ../../../../src/unvantive/shared_lib_test/err
or_handler.pc
#include "csp_dbaccess.h"
.........1
PCC-S-02015, unable to open include file
Error at line 12, column 10 in file ../../../../src/unvantive/shared_lib_test/er
ror_handler.pc
#include "csp_utilities.h"
.........1
PCC-S-02015, unable to open include file
cp -p error_handler.c /home/psatish/sandbox/csp_unvantive/src//unvantive/shared_
lib_test
$