Using Oracle ProC/C++ and Use of Global Variables

From: <bryankim_at_netspace.org>
Date: 1998/11/25
Message-ID: <73gca4$69f$1_at_nnrp1.dejanews.com>#1/1


[Quoted] The following is a problem I've encountered with use of global variables and ProC and after hitting a wall, I would greatly appreciate any input on the following question:

I am writing a C++ program which uses a BEGIN DECLARE SECTION to declare all the host variables I use throughout the program. In order to make the variables global, the DECLARE SECTION is placed outside of main within the main.C file. The problem I'm encountering is how to make globally declared host variables accessible to other .H and .C files.

While normally global variables can simply be declared in an .H file and in turn, #included in all files that access the needed variable, SQL statements such as the DECLARE SECTION may only be placed in .C files (or .pc files). This creates a problem for access to global variables that need to extend beyond the scope of one file.

For example, suppose we have three separate files: main.C, ClassOne.H, and ClassOne.C, where main.C instantiates an instance of ClassOne. If main.C contains globally declared host variables within an EXEC SQL BEGIN DECLARE SECTION, how can either ClassOne.H or ClassOne.C access the globally declared host variables back in main.C? If both #include each other, a circular include results. A forward class declaration in main.C is also insufficient if main.C not only instantiates ClassOne, but also calls member functions of the class. Does this mean there is no way to declare global host variables across several different files?

Unfortunately, the oracle manuals seem to address only single file c++ samples. Careful inspection of cppdemo1.pc, for example, illustrates a case where trying to split each class into a separate .H and .C while globally declaring the host variables back in main.C does not seem possible.

It would seem this would be a major shortcoming to writing C++ applications though hopefully in this case, is there a workaround?

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed Nov 25 1998 - 00:00:00 CET

Original text of this message