关于.pc文件编译后会多产生些代码吗?请帮我看看这段代码
.pc的内容:
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <time.h>
#include <stdarg.h>
#define CHAR_SP '\n '
EXEC SQL INCLUDE sqlca;
EXEC SQL INCLUDE sqlda;
/* Second connect to database */
int connectDb(char *sUser, char *sPwd, char *sTns, char *sPlat)
{
int nRet;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR UserName[30];
VARCHAR PassWord[30];
VARCHAR HostName[30];
VARCHAR PlatCode[30];
EXEC SQL END DECLARE SECTION;
strcpy((char *) PlatCode.arr, sPlat);
PlatCode.len = strlen((char *) PlatCode.arr);
if( connDB(sUser, sPwd, sTns) != 0 )
{
printf( "ERROR: First Connect to DB.\n " );
exit(-1);
}
printf( "\nFirst Connected to ORACLE success.\n " );
if( PlatCode.len == 0 )/* Do not need second connect to DB */
return 0;
EXEC SQL SELECT LOGIN_SERVERNAME,LOGIN_USERNAME,LOGIN_PASSWORD
into :HostName, :UserName, :PassWord
from PLAT_LOGIN_USER
WHERE PLAT_CODE= :PlatCode;
if( sqlca.sqlcode < 0 || sqlca.sqlcode > 0 )
{
printf( "ERROR: Read plat info from DB.\n " );
EXEC SQL ROLLBACK WORK RELEASE;
exit(-1);
}
/*EXEC SQL ROLLBACK WORK RELEASE; */
HostName.arr[HostName.len] = '\0 ';
UserName.arr[UserName.len] = '\0 ';
PassWord.arr[PassWord.len] = '\0 ';
nRet = EncodeAndDecode( (char *)PassWord.arr );
PassWord.len = strlen((char *) PassWord.arr);
nRet = HandleDbName( (char *)HostName.arr );
HostName.len = strlen((char *) HostName.arr);
if( connDB((char *)UserName.arr, (char *)PassWord.arr,
(char *)HostName.arr) != 0 )
{
printf( "ERROR: Connect to Second DB.\n " );
return -1;
}
printf( "Second Connected to ORACLE success.\n " );
return 0;
}
/* Connect Database */
int connDB( char *sUser, char *sPwd, char *sTns)
{
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR vUserName[32];
VARCHAR vPassWord[32];
VARCHAR vDataBase[32];
EXEC SQL END DECLARE SECTION;
strcpy( (char *)vUserName.arr, sUser);
vUserName.len = strlen( (char *)vUserName.arr );
strcpy( (char *)vPassWord.arr, sPwd);
vPassWord.len = strlen( (char *)vPassWord.arr );
strcpy( (char *)vDataBase.arr, sTns);
vDataBase.len = strlen( (char *)vDataBase.arr );
EXEC SQL CONNECT :vUserName IDENTIFIED BY :vPassWord USING :vDataBase;
if( sqlca.sqlcode < 0 )
return -1;
return 0;
}
编译后会有:
struct sqltvn
{
unsigned char *tvnvsn;
unsigned short tvnvsnl;
unsigned char *tvnnm;
unsigned short tvnnml;
unsigned char *tvnsnm;
unsigned short tvnsnml;
};
typedef struct sqltvn sqltvn;
struct sqladts
{
unsigned int adtvsn;
unsigned short adtmode;
unsigned short adtnum;
sqltvn adttvn[1];
};
typedef struct sqladts sqladts;
...............
static struct sqlexd {
unsigned int sqlvsn;
unsigned int arrsiz;
unsigned int iters;
unsigned int offset;
unsigned short selerr;
unsigned short sqlety;
unsigned int occurs;
short *cud;
unsigned char *sqlest;
char *stmt;
sqladts *sqladtp;
sqltdss *sqltdsp;
void **sqphsv;
unsigned int *sqphsl;
int *sqphss;
void **sqpind;
int *sqpins;
unsigned int *sqparm;
unsigned int **sqparc;
unsigned short *sqpadto;
unsigned short *sqptdso;
unsigned int sqlcmax;
unsigned int sqlcmin;
unsigned int sqlcincr;
unsigned int sqlctimeout;
unsigned int sqlcnowait;
int sqfoff;
unsigned int sqcmod;
unsigned int sqfmod;
void *sqhstv[4];
unsigned int sqhstl[4];
int sqhsts[4];
void *sqindv[4];
int sqinds[4];
unsigned int sqharm[4];
unsigned int *sqharc[4];
unsigned short sqadto[4];
unsigned short sqtdso[4];
} sqlstm = {12,4};
/* EXEC SQL SELECT LOGIN_SERVERNAME,LOGIN_USERNAME,LOGIN_PASSWORD
into :HostName, :UserName, :PassWord
from PLAT_LOGIN_USER
WHERE PLAT_CODE= :PlatCode; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 12;
sqlstm.arrsiz = 4;
sqlstm.sqladtp = &sqladt;
sqlstm.sqltdsp = &sqltds;
sqlstm.stmt = "select LOGIN_SERVERNAME ,LOGIN_USERNAME ,LOGIN_PASSWORD into\
:b0,:b1,:b2 from PLAT_LOGIN_USER where PLAT_CODE=:b3 ";
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )5;
sqlstm.selerr = (unsigned short)1;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)256;
sqlstm.occurs = (unsigned int )0;
sqlstm.sqhstv[0] = ( void *)&HostName;
sqlstm.sqhstl[0] = (unsigned int )32;
sqlstm.sqhsts[0] = ( int )0;
sqlstm.sqindv[0] = ( void *)0;
sqlstm.sqinds[0] = ( int )0;
sqlstm.sqharm[0] = (unsigned int )0;
sqlstm.sqadto[0] = (unsigned short )0;
sqlstm.sqtdso[0] = (unsigned short )0;
sqlstm.sqhstv[1] = ( void *)&UserName;
sqlstm.sqhstl[1] = (unsigned int )32;
sqlstm.sqhsts[1] = ( int )0;
sqlstm.sqindv[1] = ( void *)0;
sqlstm.sqinds[1] = ( int )0;
sqlstm.sqharm[1] = (unsigned int )0;
sqlstm.sqadto[1] = (unsigned short )0;
sqlstm.sqtdso[1] = (unsigned short )0;
sqlstm.sqhstv[2] = ( void *)&PassWord;
sqlstm.sqhstl[2] = (unsigned int )32;
sqlstm.sqhsts[2] = ( int )0;
sqlstm.sqindv[2] = ( void *)0;
sqlstm.sqinds[2] = ( int )0;
sqlstm.sqharm[2] = (unsigned int )0;
sqlstm.sqadto[2] = (unsigned short )0;
sqlstm.sqtdso[2] = (unsigned short )0;
sqlstm.sqhstv[3] = ( void *)&PlatCode;
sqlstm.sqhstl[3] = (unsigned int )32;
sqlstm.sqhsts[3] = ( int )0;
sqlstm.sqindv[3] = ( void *)0;
sqlstm.sqinds[3] = ( int )0;
sqlstm.sqharm[3] = (unsigned int )0;
sqlstm.sqadto[3] = (unsigned short )0;
sqlstm.sqtdso[3] = (unsigned short )0;
sqlstm.sqphsv = sqlstm.sqhstv;
sqlstm.sqphsl = sqlstm.sqhstl;
sqlstm.sqphss = sqlstm.sqhsts;
sqlstm.sqpind = sqlstm.sqindv;
sqlstm.sqpins = sqlstm.sqinds;
sqlstm.sqparm = sqlstm.sqharm;
sqlstm.sqparc = sqlstm.sqharc;
sqlstm.sqpadto = sqlstm.sqadto;
sqlstm.sqptdso = sqlstm.sqtdso;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}
这些看都看不懂也不知道哪里来的
[解决办法]
.pc文件用proc编译,proc iname=xx.pc , 产生c文件xx.c;
再用cc或gcc编译xx.c ,之后才能产生二进制文件
[解决办法]
oracle : .pc文件用proc编译,proc iname=xx.pc , 产生c文件xx.c;
[解决办法]
在用Proc C的情况下.pc才是源码,.c是中间文件。
LZ问到的.c文件里那些代码是Proc C进行预处理的结果!其实代码里都有注释的
比如下面的这一段,注释掉的内容预处理的结果就是是接下来花括号 "{} "之间的C语言语句!
/* EXEC SQL SELECT LOGIN_SERVERNAME,LOGIN_USERNAME,LOGIN_PASSWORD
into :HostName, :UserName, :PassWord
from PLAT_LOGIN_USER
WHERE PLAT_CODE= :PlatCode; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 12;
sqlstm.arrsiz = 4;
sqlstm.sqladtp = &sqladt;
sqlstm.sqltdsp = &sqltds;
sqlstm.stmt = "select LOGIN_SERVERNAME ,LOGIN_USERNAME ,LOGIN_PASSWORD into\
:b0,:b1,:b2 from PLAT_LOGIN_USER where PLAT_CODE=:b3 ";
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )5;
sqlstm.selerr = (unsigned short)1;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)256;
sqlstm.occurs = (unsigned int )0;
sqlstm.sqhstv[0] = ( void *)&HostName;
sqlstm.sqhstl[0] = (unsigned int )32;
sqlstm.sqhsts[0] = ( int )0;
sqlstm.sqindv[0] = ( void *)0;
sqlstm.sqinds[0] = ( int )0;
sqlstm.sqharm[0] = (unsigned int )0;
sqlstm.sqadto[0] = (unsigned short )0;
sqlstm.sqtdso[0] = (unsigned short )0;
sqlstm.sqhstv[1] = ( void *)&UserName;
sqlstm.sqhstl[1] = (unsigned int )32;
sqlstm.sqhsts[1] = ( int )0;
sqlstm.sqindv[1] = ( void *)0;
sqlstm.sqinds[1] = ( int )0;
sqlstm.sqharm[1] = (unsigned int )0;
sqlstm.sqadto[1] = (unsigned short )0;
sqlstm.sqtdso[1] = (unsigned short )0;
sqlstm.sqhstv[2] = ( void *)&PassWord;
sqlstm.sqhstl[2] = (unsigned int )32;
sqlstm.sqhsts[2] = ( int )0;
sqlstm.sqindv[2] = ( void *)0;
sqlstm.sqinds[2] = ( int )0;
sqlstm.sqharm[2] = (unsigned int )0;
sqlstm.sqadto[2] = (unsigned short )0;
sqlstm.sqtdso[2] = (unsigned short )0;
sqlstm.sqhstv[3] = ( void *)&PlatCode;
sqlstm.sqhstl[3] = (unsigned int )32;
sqlstm.sqhsts[3] = ( int )0;
sqlstm.sqindv[3] = ( void *)0;
sqlstm.sqinds[3] = ( int )0;
sqlstm.sqharm[3] = (unsigned int )0;
sqlstm.sqadto[3] = (unsigned short )0;
sqlstm.sqtdso[3] = (unsigned short )0;
sqlstm.sqphsv = sqlstm.sqhstv;
sqlstm.sqphsl = sqlstm.sqhstl;
sqlstm.sqphss = sqlstm.sqhsts;
sqlstm.sqpind = sqlstm.sqindv;
sqlstm.sqpins = sqlstm.sqinds;
sqlstm.sqparm = sqlstm.sqharm;
sqlstm.sqparc = sqlstm.sqharc;
sqlstm.sqpadto = sqlstm.sqadto;
sqlstm.sqptdso = sqlstm.sqtdso;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}