Oracle Pro*C precompiler errors on EXEC SQL statements in included files
I'开发者_如何学JAVAm converting some legacy code to Oracle Pro*C. I'm on a Linux box using Oracle 11.2. We are using ".cp" as the suffix for Pro*C source files. I'm not much of a C developer so I am sort of banging around in the dark as I go.
At one point I have some code in a shared library file, "assign_field.cp," so in myprog.cp I am doing
EXEC SQL INCLUDE "assign_field.cp";
Now, in assign_field.cp, I have a very common line of Pro*C code...
EXEC SQL INCLUDE SQLCA;
For this line, along with many others, I am seeing the following compiler output:
assign_field.cp:35: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âSQLâ
It looks as though the compiler isn't recognizing that this is Pro*C code.
I've got other include files that look very similar to assign_field.cp but which appear to compile just fine when included.
Don't include the C files (in this case, .cp files) in the program's flow. Compile them separately; refer only to the function's declaration, such as in an included .h file. Refer to the compiled object files (probably .o) in the call to the linker in the makefile.
精彩评论