Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re:GNU C + Pro*C Help?
Walter,
Since I just finished pulling a pile of hair out on a similar, although not identical, problem yesterday he might look to see if things are the same. In Pro*C we use a data type called a VARCHAR inside the Oracle declare section. Something like:
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR name[50];
EXEC SQL END DECLARE SECTION;
When you run it through the precompiler that changes to:
struct
{
char arr[50];
int len;
}name;
A common problem is to forget that 'name' actually has to be referenced as 'name.arr' in C. My problem was:
sprintf(msg, "%s\0", name);
Instead of
sprintf(msg, "%s\0", name.arr);
Also Pro*C does NOT null terminate character strings when they are returned. A common thing to do is: name.arr[name.len] = '\0'. Your friend may not have null terminated things, although since it's an fgets() call it's probably not that. Probably more like:
fgets(name, sizeof(name), fp);
Instead of:
fgets(name.arr, sizeof(name.arr), fp);
Dick Goulet
____________________Reply Separator____________________ Author: "Kirsch; Walter J (Northrop Grumman)" <walter.kirsch-eds_at_eds.com> Date: 12/13/2002 8:37 AM
>From a fellow employee of mine:
"I am in the process of upgrading from an Oracle 7.3.4 environment using Pro*C and an HP 32-bit C Compiler (version A.10.32) to an Oracle 8.1.7 64-bit environment using 64-bit Pro*C and a GNU (gcc) 64-bit C Compiler. All software is on an HP UNIX version 11.00 box.
Specifically, during runtime I am experiencing a SEGMENTATION Fault on the /usr/lib/libc.2 library when the program executes a fgets() C-statement. "
Is this obvious to the initiated? Thanks for any help.
The only thing worse in the world than being talked about is not being
talked about.
-- Oscar Wilde
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Kirsch, Walter J (Northrop Grumman) INET: walter.kirsch-eds_at_eds.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: dgoulet_at_vicr.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Fri Dec 13 2002 - 12:44:17 CST
![]() |
![]() |