Oracle文档链接如下:http://docs.oracle.com/cd/E11882_01/appdev.112/e10825/pc_agsmp.htm
其中值得注意的有:
1. 使用exec sql include包含文件的使用。搜素顺序如下附录1。
2. parse对预编译产生的影响。
INCLUDE
Specifies a directory path for files included using the #include or EXEC SQL INCLUDE directives.
INCLUDE=pathname or INCLUDE=(path_1,path_2,...,path_n)
Current directory and paths built into Pro*C/C++.
Can be entered inline or on the command line.
You use INCLUDE to specify a directory path for included files. The precompiler searches directories in the following order:
-
the current directory
-
the system directory specified in a SYS_INCLUDE precompiler option
-
the directories specified by the INCLUDE option, in the order they are entered
-
the built-in directories for standard header files
You normally do not need to specify a directory path for Oracle-specific header files such as sqlca.h
and sqlda.h
.
Note:
If you specify an Oracle-specific filename without an extension for inclusion, Pro*C/C++ assumes an extension of.h
. So, included files should have an extension, even if it is not
.h
.
For all other header files, the precompiler does not assume a .h
extension.
You must still use INCLUDE to specify directory paths for non-standard files, unless they are stored in the current directory. You can specify more than one path on the command line, as follows:
... INCLUDE=path_1 INCLUDE=path_2 ...
Note:
If the file you want to include resides in another directory, make sure that there is no file with the same name in the current directory.The syntax for specifying a directory path using the INCLUDE option is system specific. Follow the conventions used for your operating system
Note:
For the INCLUDE option, the precedence of option values gets reversed. Unlike other options in which the values get overwritten, INCLUDE appends all the directory files that are mentioned in:-
Precompiler
-
Pro*C/C++ system configuration file
-
Pro*C/C++ user configuration file
-
Command line
-
Inline
However, there is a difference between passing values within or without brackets. If you pass a single value or directory list within brackets, then the existing value of INCLUDE is overwritten. If you pass the list as a simple value without brackets, it will supplement any existing value.
Parsing Code
You must be able to control the effect of the Pro*C/C++ C parser on your code. You do this by using the PARSE precompiler option, which controls how the precompiler's C parser treats your code.
The values and effects of the PARSE option are:
Table 12-1 Values and Effects of the PARSE Option
Values | Effects |
---|---|
PARSE=NONE | The value NONE has the following effects:
|
PARSE=PARTIAL | The value PARTIAL has the following effects:
This option value is the default if CODE=CPP |
PARSE=FULL | The value FULL has the following effects:
|
This option value is the default if the value of the CODE option is anything other than CPP. It is an error to specify PARSE=FULL when CODE=CPP.
To generate C++ compatible code, the PARSE option must be either NONE or PARTIAL. If PARSE=FULL, the C parser runs, and it does not understand C++ constructs in your code, such as classes.
Output Filename Extension
Most C compilers expect a default extension of ".c" for their input files. Different C++ compilers, however, can expect different filename extensions. The CPP_SUFFIX option provides the ability to specify the filename extension that the precompiler generates. The value of this option is a string, without the quotes or the period. For example, CPP_SUFFIX=cc, or CPP_SUFFIX=C.
System Header Files
Pro*C/C++ searches for standard system header files, such as stdio.h
, in standard locations that are platform specific. Pro*C/C++ does not search for header files with extensions such as hpp
or h
++. For example, on almost all UNIX systems, the file stdio.h
has the full path name /usr/include/stdio.h
.
But a C++ compiler has its own version of stdio.h
that is not in the standard system location. When you are precompiling for C++, you must use the SYS_INCLUDE precompiler option to specify the directory paths that Pro*C/C++ searches to look for system header files. For example:
SYS_INCLUDE=(/usr/lang/SC2.0.1/include,/usr/lang/SC2.1.1/include)
Use the INCLUDE precompiler option to specify the location of non-system header files. The directories specified by the SYS_INCLUDE option are searched before directories specified by the INCLUDE option. See also: "INCLUDE".
If PARSE=NONE, the values specified in SYS_INCLUDE and INCLUDE for system files are not relevant, since there is no need for Pro*C/C++ to include system header files. (You can, of course, still include Pro*C/C++-specific headers, such sqlca.h
, using the EXEC SQL INCLUDE statement.)