Pro*C/C++ Precompiler Getting Started Release 8.1.6 for Windows Part Number A73023-01 |
|
This chapter explains how to create and precompile a project. It also describes the Pro*C/C++ graphical user interface, from which you execute commands with Windows menus and icons or with keyboard equivalents, and using Pro*C/C++ at the command line. Specific topics discussed are:
Before you follow the instructions for creating and precompiling a Pro*C/C++ project, you should familiarize yourself with the basic commands, dialog boxes, menus, and buttons of the Pro*C/C++ graphical user interface.
To start the graphical user interface, choose Start > Programs > Oracle - HOME_NAME > Application Development > Pro C_C++.
The Pro*C/C++ precompile environment contains five elements noted in the following illustration:
Text description of the illustration ch2a.gif.
The title bar displays the name of the Pro*C/C++ project. If you have not assigned a name to the current project, the word "Untitled" appears instead.
The menu bar contains the following menus:
The toolbar enables you to execute commands by clicking a button:
Text description of the illustration ch27.gif.
The information pane consists of four elements noted in the following illustration:
Text description of the illustration ch29.gif.
Look for one of the three status icons in the precompilation status bar after the precompile process is complete.
Double clicking a status icon opens the Precompilation Status dialog box. This dialog box provides detailed information on the reason for a warning or failure.
The status bar at the bottom of the window displays information about the progress of a precompilation. The status bar also identifies the purpose of a toolbar button or menu command when you place the mouse pointer over the toolbar button or menu command.
This section describes the steps involved in creating and precompiling a Pro*C/C++ project. After starting the Pro*C/C++ application, perform the following steps:
Pro*C/C++ opens only one project at a time. A project consists of one or more precompilable files. Project files have an extension of .pre
.
Use the Preferences menu to determine the default extension of the output files.
Text description of the illustration prefs.gif.
This setting only affects input files that you add later. An existing output file name will not change. However, you can change an existing output file name by double-clicking the output file and entering a new name.
.c
.
.cpp
.
.pc
files. Use the Ctrl key and the mouse to select files that are not adjacent.
If you need to, you can easily delete one or more files from the project.
The Precompiler options enable you to control how resources are used, how errors are reported, how input and output are formatted, and how cursors are managed.
Text description of the illustration options.gif.
Default options are in effect for all newly added files. When you change an option's default setting, a description of the change appears in the Option String edit field at the bottom of the Options dialog box and in the Options area of the information pane. For additional information on options, see "Precompiler Options".
Text description of the illustration listerr.gif.
The settings include the type of error information generated and the name of the list file.
If you selected semantics or full for the SQL Check option in the Options dialog box, you may need to specify database connection information to the Oracle database. You do not need to connect to the Oracle database if every table referenced in a data manipulation statement or PL/SQL block is defined in a DECLARE TABLE statement.
You can precompile any number of files in the Input File list.
When precompiling is completed, the message in the dialog box indicates "Precompiling Finished!
", and the Cancel button changes to OK.
Precompiling can result in success, success with warning(s), or failure. When precompiling is finished, check the precompilation status bar.
If you see a yellow check or a red X, double-click the icon in status bar. The Precompilation Status dialog box appears. This dialog box lists warning messages or reasons why the precompilation failed. For example:
Text description of the illustration error.gif.
Switch to your development environment to fix the problem(s). After you correct the errors, precompile again.
To exit Pro*C/C++, choose File > Exit. If your project changed in any way, you are prompted to save it.
To precompile a file at the command line, enter the following command:
C:\> proc iname=filename.pc
where filename.pc
is the name of the file. If the file is not in your current working directory, include the file's full path after the INAME argument.
Pro*C/C++ generates filename.c
, which can be compiled by your C compiler.
The oracle_base
\
oracle_home
\precomp\public
directory contains the Pro*C/C++ header files.
See Also:
See the Pro*C/C++ Precompiler Programmer's Guide for more information about |
The oracle_base
\
oracle_home
\precomp\lib\msvc
directory contains the library file that you use when linking Pro*C/C++ applications. The library file is called orasql8.lib
.
Pro*C/C++ application program interface (API) calls are implemented in DLL files provided with your Pro*C/C++ software. To use the DLLs, you must link your application with the import libraries (.lib files) that correspond to the Pro*C/C++ DLLs. Also, you must ensure that the DLL files are installed on the computer that is running your Pro*C/C++ application.
Microsoft provides you with three libraries: libc.lib
, libcmt.lib
, and msvcrt.lib
. The Oracle DLLs use the msvcrt.lib
runtime library. You must link with msvcrt.lib
rather than the other two Microsoft libraries.
Build multi-threaded applications if you are planning to perform concurrent database operations.
Windows NT and Windows 95/98 schedule and allocate threads belonging to processes. A thread is a path of a program's execution. It consists of a kernel stack, the state of the CPU registers, a thread environment block, and a users stack. Each thread shares the resources of a process. Multi-threaded applications use the resources of a process to coordinate the activities of individual threads.
When building a multi-threaded application, make sure that your C/C++ code is reentrant. This means that access to static or global data must be restricted to one thread at a time. If you mix multi-threaded and non-reentrant functions, one thread can modify information that is required by another thread.
The Pro*C/C++ precompiler automatically creates variables on the local stack of the thread. This ensures that each thread using the Pro*C/C++ function has access to a unique set of variables and is reentrant.
See Also:
See the Pro*C/C++ Precompiler Programmer's Guide for additional information on how to write multi-threaded applications with Pro*C/C++. |
This section highlights issues related to Pro*C/C++ for Windows platforms.
See Also:
See the "Precompiler Options" chapter of the Pro*C/C++ Precompiler Programmer's Guide for more information on the precompiler options. |
A configuration file is a text file that contains precompiler options.
For this release, the system configuration file is called pcscfg.cfg
. This file is located in the oracle_base
\
oracle_home
\precomp\admin
directory.
The CODE option has a default setting of ANSI_C. Pro*C/C++ for other operating systems may have a default setting of KR_C.
DBMS=V6_CHAR is not supported when using CHAR_MAP=VARCHAR2. Instead, use DBMS=V7.
For the Pro*C/C++ graphical user interface, use the Include Directories field of the Options dialog box to enter INCLUDE path directories. If you want to enter more than one path, separate each path with a semicolon, but do not insert a space after the semicolon. This causes a separate "INCLUDE=" string to appear in front of each directory.
For sample programs that precompile with PARSE=PARTIAL or PARSE=FULL, an include path of c:\program files\devstudio\vc\include
has been added. If Microsoft Visual C++ has been installed in a different location, modify the Include Directories field accordingly for the sample programs to precompile correctly.
The PARSE option has a default setting of NONE. Pro*C/C++ for other operating systems may have a default setting of FULL.
The XA Application Program Interface (API) is typically used to enable an Oracle database to interact with a transaction processing (TP) monitor, such as:
You can also use TP monitor statements in your client programs. The use of the XA API is also supported from both Pro*C/C++ and OCI.
The Oracle XA Library is automatically installed as part of Oracle8i Enterprise Edition. The following components are created in your Oracle home directory:
Component | Location |
---|---|
|
|
|
|
To compile and link a Pro*C/C++ program with XA:
filename
.pc
using Pro*C/C++ to generate filename.c
.
filename
.c
, making sure to include oracle_base
\
oracle_home
\rdbms\xa
in your path.
filename
.obj
with the following libraries:
Library | Location |
---|---|
|
|
|
|
|
|
filename
.exe
.
Oracle supports the use of XA dynamic registration. XA dynamic registration improves the performance of applications that interface with XA-compliant TP monitors.
For TP monitors to use XA dynamic registration with an Oracle database on Windows NT, you must add either an environmental variable or a registry variable to the Windows NT computer on which your TP monitor is running. See either of the following sections for instructions:
Adding an environmental variable at the MS-DOS command prompt affects only the current MS-DOS session.
To add an environmental variable for the current session:
C:\> set ORA_XA_REG_DLL = vendor.dll
where vendor
.dll
is the TP monitor DLL provided by your vendor.
Adding a registry variable affects all sessions on your Windows NT computer. This is useful for computers where only one TP monitor is running.
To add a registry variable for all sessions:
C:\> regedit
The Registry Editor window appears.
The Add Value dialog box appears.
The String Editor dialog box appears.
vendor
.dll
in the String field, where vendor
.dll
is the TP monitor DLL provided by your vendor.
The Registry Editor adds the parameter.
The registry exits.
Refer to the following for more information about XA and TP monitors:
http://www.opengroup.org/publications/catalog/tp.htm
For more information about the Oracle XA Library
and using XA dynamic registration, see Oracle8i
Application Developer's Guide - Fundamentals.
See
Also:
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|