关于MySQL++编译出现大量Warning问题

nethermit 2002-06-10 01:46:53
编译可以通过,也可以用,就是有大量Warning,请教各位哪里没搞好导致的?
...全文
156 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Athealy 2002-11-20
  • 打赏
  • 举报
回复
我也遇到同样的问题。外加一个"code in header"的错误。我是在学BCB。
nethermit 2002-07-10
  • 打赏
  • 举报
回复
我已经把他们都Disable了
dejoy 2002-07-09
  • 打赏
  • 举报
回复
这些警告没有什么嘛,是一些类型转换警告,没什么的.
nethermit 2002-06-13
  • 打赏
  • 举报
回复
我用下来MySQL++不错啊,好东西,而且对于STL支持很好,简单封装费时间,用现成的吧
pi1ot 2002-06-12
  • 打赏
  • 举报
回复
MySQL++编译起来太麻烦,还是用C的了,或者自己写一个简单的C++封装。
nethermit 2002-06-10
  • 打赏
  • 举报
回复
非也非也,不是你说的那个
我对于MySQL的C API和ODBC都比较了解,编程没问题。
我说的是MySQL++,一个C++类库,对STL支持比较好,你可以到www.mysql.com去下载MySQL++。我碰到前面说的那个问题,比较麻烦点。:(
webmin 2002-06-10
  • 打赏
  • 举报
回复
你是说mysql\examples\libmysqltest目录下那个例子,不好意思我不会用VC,我给你一段代码吧。
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <mysql.h>

int main(int argc, char* argv[])
{
char szTargetDSN[] = "test";
char szSqlText[500]="";
char aszFlds[ 25 ][ 25 ];
MYSQL * myData ;
MYSQL_RES * res ;
MYSQL_FIELD * fd ;
MYSQL_ROW row ;
int i,j,k;
bool bCreate = TRUE;
if ( (myData = mysql_init((MYSQL*) 0)) && mysql_real_connect( myData, "192.168.1.1","", "", szTargetDSN, MYSQL_PORT, NULL, 0 ) ) //初始化数据结构 连接数据库
{
if(bCreate)
{
sprintf(szSqlText,"create table mytable1 (time datetime, s1 char(6),s2 char(11), s3 int, s4 int)");//构造SQL语句//新建一张表
if (mysql_query( myData, szSqlText))
//执行SQL语句
{//执行SQL语句出错
printf( "Can't create table") ;
mysql_close( myData ) ;
return FALSE ;
}
}
sprintf(szSqlText,"insert into mytable1 values('2000-3-10 21:01:30','Test','MySQLTest',2000,3)"); //向表中插入数据 //注意时间的格式
if (mysql_query( myData, szSqlText))
{//执行SQL语句出错
printf( "Can't insert data to table") ;
mysql_close( myData ) ;
return FALSE ;
}
sprintf(szSqlText, "select * from mytable1 ");
if (mysql_query( myData, szSqlText))
//进行数据检索
{ //执行SQL语句出错
mysql_close( myData ) ;
return FALSE ;
}
else
{
res = mysql_store_result( myData ) ;
//取得查询结果
i = (int) mysql_num_rows( res ) ;
//取得有效记录数
printf( "Query: %s\n%ld records found:\n", szSqlText, i ) ;
for ( i = 0 ; fd = mysql_fetch_field( res ) ; i++ ){
strcpy( aszFlds[ i ], fd->name ) ;//取得各字段名
}
for (i=1; row = mysql_fetch_row( res ); ){
j = mysql_num_fields( res ) ;//依次读取各条记录
printf( "Record #%ld:-\n", i++ ) ; //取得记录中的字段数
for ( k = 0 ; k < j ; k++ )
//输出各字段的值
printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
(((row[k]==NULL)||
(!strlen(row[k])))?"NULL":row[k])) ;
puts( "==============================\n" ) ;
}
mysql_free_result( res ) ;
}
}
else
{//连接数据库出错
printf( "Can't connect to the mysql server ") ;
mysql_close( myData ) ;
return FALSE ;
}
mysql_close( myData ) ;
return 0;
}

注意两点:
1、在工程的链接选项中,加入c:\mysql\lib\libmysql.lib的接口库,把libmysql.dll复制到操作系统的system目录下(c:\winnt\system32)
2、把“c:\mysql\include”添加到编译选项的包含路径中(在Project Options中加入 /I "d:\mysql\include")
nethermit 2002-06-10
  • 打赏
  • 举报
回复
就是那个MFC_example,请教啦,不过这些Warning不用去管,一样可以用。
...mysql++\include\type_info1.hh(39) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
...mysql++\include\type_info1.hh(159) : warning C4800: 'unsigned int' : forcing value to bool 'true' or 'false' (performance warning)
...mysql++\include\type_info1.hh(172) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
...mysql++\include\type_info1.hh(176) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
...mysql++\include\type_info1.hh(180) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
...mysql++\include\type_info1.hh(184) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
...mysql++\include\convert1.hh(40) : warning C4273: 'strtol' : inconsistent dll linkage. dllexport assumed.
...mysql++\include\convert1.hh(41) : warning C4273: 'strtoul' : inconsistent dll linkage. dllexport assumed.
...mysql++\include\sql_query1.hh(37) : warning C4800: 'class SQLQuery *' : forcing value to bool 'true' or 'false' (performance warning)
...mysql++\include\sql_query1.hh(135) : warning C4355: 'this' : used in base member initializer list
...mysql++\include\compare1.hh(48) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
...mysql++\include\result1.hh(33) : warning C4355: 'this' : used in base member initializer list
...mysql++\include\result1.hh(42) : warning C4800: 'char' : forcing value to bool 'true' or 'false' (performance warning)
...microsoft visual studio\vc98\include\utility(25) : warning C4786: 'std::_Tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const
,int>,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,int,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<int> >::_Kfn,std::less<std::basic_string<char,std::char_traits<ch
ar>,std::allocator<char> > >,std::allocator<int> >::iterator' : identifier was truncated to '255' characters in the debug information
...microsoft visual studio\vc98\include\map(93) : see reference to class template instantiation 'std::pair<std::_Tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<std::basic_string<char,std::ch
ar_traits<char>,std::allocator<char> > const ,int>,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,int,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<int> >::_Kfn,std::le
ss<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<int> >::iterator,bool>' being compiled
...microsoft visual studio\vc98\include\map(93) : while compiling class-template member function 'int &__thiscall std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,int,std::less<std::basic_string<cha
r,std::char_traits<char>,std::allocator<char> > >,std::allocator<int> >::operator [](const std::basic_string<char,std::char_traits<char>,std::allocator<char> > &)'
Generating Code...
webmin 2002-06-10
  • 打赏
  • 举报
回复
附带的例子有好多,你是指那一个。
nethermit 2002-06-10
  • 打赏
  • 举报
回复
就是MySQL++附带的例子,没有改动过,直接拿来用,各种路径都设置好了
webmin 2002-06-10
  • 打赏
  • 举报
回复
你不吧代码贴出来谁知道为什么会出现大量Warning。

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧