免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3525 | 回复: 4
打印 上一主题 下一主题

PRO*C为什么我只要加<pthread.h>就报错,谢谢 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-02-04 09:31 |只看该作者 |倒序浏览
您好!PRO*C为什么我只要加<pthread.h>就报错,测试程序当然没有问题,我想用多线程的PRO*C。请问怎样改MAKEFILE(已经加了THREADS=YES),我用的OS是AIX,不用pro*c,能支持多线程。
程序如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlca.h>
/*#include <pthread.h>*/
#include "lib1.h"


void sql_error(char *msg);

EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR     username[30];
VARCHAR     password[30];
EXEC SQL END DECLARE SECTION;

int main(int argc, char **argv)
{
Print("333333333333333333333333\n");
strncpy((char *) username.arr, "gdianu01", strlen("gdianu01"));
username.len = (unsigned short) strlen((char *)username.arr);

strncpy((char *) password.arr, "964218", strlen("964218"));
password.len = (unsigned short) strlen((char *)password.arr);

EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");
EXEC SQL CONNECT :username IDENTIFIED BY :password;

EXEC SQL WHENEVER SQLERROR DO sql_error("insert--\n");

EXEC SQL INSERT INTO user_info VALUES('1111', '2222');

EXEC SQL ROLLBACK WORK RELEASE;
printf("connect suceccss\n");

exit(0);
}

void sql_error(char *msg)
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
if (sqlca.sqlcode < 0)
   printf("\n%.*s\n\n",sqlca.sqlerrm.sqlerrml,sqlca.sqlerrm.sqlerrmc);
printf("oracle error:%s\n", msg);
EXEC SQL ROLLBACK WORK RELEASE;
exit(-1);
}

错误如下:

$ make all
        proc sqlcheck=full userid=gdianu01/964218 iname=/app/gdian/test/src/pre.pc include=/app/gdian/test/include

Pro*C/C++: Release 9.2.0.1.0 - Production on Sat Feb 3 12:40:12 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

System default option values taken from: /oracle9/OraHome/precomp/admin/pcscfg.cfg

Parser error at line 689, column 32, file /usr/include/sys/thread.h:
Error at line 689, column 32 in file /usr/include/sys/thread.h
        sigset_t        sigmask;
...............................1
PCC-F-02209, Macro invocation has incorrect number of arguments
Syntax error at line 689, column 25, file /usr/include/sys/thread.h:
Error at line 689, column 25 in file /usr/include/sys/thread.h
        sigset_t        sigmask;
........................1
PCC-S-02201, Encountered the symbol "1" when expecting one of the following:

   ( * an identifier,

Syntax error at line 689, column 25, file /usr/include/sys/thread.h:
Error at line 689, column 25 in file /usr/include/sys/thread.h
        sigset_t        sigmask;
........................1
PCC-S-02201, Encountered the symbol ")" when expecting one of the following:

   ; , ( [ * ? | & < > + - / % . ^ | & == != <= >= << >> ++ --
   ->
The symbol "(" was substituted for ")" to continue.

Syntax error at line 18, column 1, file /app/gdian/test/src/pre.pc:
Error at line 18, column 1 in file /app/gdian/test/src/pre.pc
{
1
PCC-S-02201, Encountered the symbol "{" when expecting one of the following:

   ; , = ( [
The symbol ";" was substituted for "{" to continue.

Syntax error at line 40, column 1, file /app/gdian/test/src/pre.pc:
Error at line 40, column 1 in file /app/gdian/test/src/pre.pc
{
1
PCC-S-02201, Encountered the symbol "{" when expecting one of the following:

   ; , = ( [
The symbol ";" was substituted for "{" to continue.

Syntax error at line 0, column 0, file /app/gdian/test/src/pre.pc:
Error at line 0, column 0 in file /app/gdian/test/src/pre.pc
PCC-S-02201, Encountered the symbol "<eof>" when expecting one of the following:

   ; { } ( * & + - ~ ! ^ ++ -- ... auto, break, case, char,
   const, continue, default, do, double, enum, extern, float,
   for, goto, if, int, long, ulong_varchar, OCIBFileLocator
   OCIBlobLocator, OCIClobLocator, OCIDateTime,
   OCIExtProcContext, OCIInterval, OCIRowid, OCIDate, OCINumber,
   OCIRaw, OCIString, register, return, short, signed, sizeof,
   sql_context, sql_cursor, static, struct, switch, typedef,
   union, unsigned, utext, uvarchar, varchar, void, volatile,
   while, an identifier, a typedef name, a precompiled header,
   a quoted string, a numeric constant, exec oracle,
   exec oracle begin, exec, exec sql, exec sql begin,
   exec sql type, exec sql var, exec sql include,

Error at line 0, column 0 in file /app/gdian/test/src/pre.pc
PCC-F-02102, Fatal error while doing C preprocessing
make: 1254-004 The error code from the last command is 1.


Stop.

论坛徽章:
0
2 [报告]
发表于 2007-02-04 09:40 |只看该作者
好象跟那个头文件没有问题吧!
make有问题

论坛徽章:
0
3 [报告]
发表于 2007-02-04 09:47 |只看该作者

RE

原帖由 我晕啊 于 2007-2-4 09:40 发表
好象跟那个头文件没有问题吧!
make有问题

MAKEFILE里增加了threads=yes,如果去掉#include<pthread.h>,就没有问题。

论坛徽章:
0
4 [报告]
发表于 2007-02-04 10:49 |只看该作者
-lpthread

论坛徽章:
0
5 [报告]
发表于 2007-02-04 11:19 |只看该作者

re

原帖由 高峰 于 2007-2-4 10:49 发表
-lpthread

也用了,谢谢,还是不行。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP