![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
原创
yaochunnian
执行力!
展开
-
gcc/g++如何指定只链接静态库?
Question Description:一个目录下同时存在libtest.a和libtest.so时,gcc/g++用-ltest链接时默认链接的是动态库,可以通过-static来使gcc/g++强制链接静态库libtest.a,可是这会让gcc/g++对所有的库都只链接其静态库,如何指定对某个库链接静态库而对另外一个库链接动态库?原创 2011-12-10 16:02:49 · 3707 阅读 · 1 评论 -
通过事务实现互斥
1.可以实现互斥:select...for update 与select...for update之间的互斥事务A:$ret = mysql_query("BEGIN",$con);$sql = "select * from taskstatus where aid=300 for update";$ret = mysql_query($sql,$con);sleep(10原创 2012-12-11 13:56:38 · 374 阅读 · 0 评论 -
insert ... for duplicate key update ...
$sql = "insert into groupquota (ugid,concurrent,compute) ". "values($ugid,$concurrent,$compute) on duplicate key update ". "concurrent=concurrent-$concurrent,compute=co原创 2012-12-15 15:14:26 · 230 阅读 · 0 评论 -
mysql数据库左/右 内/外连接使用方法
(1).表A和B的描述mysql> desc A;+-------+------------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+------------------+------+-----+------原创 2012-12-13 18:21:17 · 345 阅读 · 0 评论 -
mysql 数据库外键使用
1.创建表A,id为主键create table A(id int unsigned primary key not null,name varchar(128) not null)Engine=InnoDB,CHARSET=utf8;2.创建表B,id为来自于表A的id字段的外键,create table B(id int unsigned primary key not n原创 2012-12-13 16:31:28 · 282 阅读 · 0 评论 -
php中访问本类成员需用$this
如下代码:class A{private $DAInfo; public function init() { $this->DAInfo = NULL; //如果不用$this即:$DAInfo = NULL;则相当于这里定义了一个临时变量!! $this->DAInfo = DataAlgoInfo::getInst原创 2012-11-23 14:14:50 · 281 阅读 · 0 评论 -
php mysql 创建及使用procedure的例子
$con = mysql_connect("localhost","root","root"); if (false == $con) { printf("%s,%s,%s\n",__FILE__,__FUNCTION__,__LINE__); } $ret = mysql_select_db("algoplat",$con); if (原创 2012-12-01 16:48:59 · 322 阅读 · 0 评论 -
php mysql事务的例子
$con = mysql_connect("localhost","root","root"); if (false == $con) { printf("%s,%s,%s\n",__FILE__,__FUNCTION__,__LINE__); exit(1); } $ret = mysql_select_db("algoplat原创 2012-12-01 15:56:36 · 239 阅读 · 0 评论 -
php操作mysql的例子
//连接数据库 $con = mysql_connect("localhost","root","root"); if (false == $con) { printf("%s,%s,%s\n",__FILE__,__FUNCTION__,__LINE__); } //选择数据库 $ret = mysql_selec原创 2012-12-01 15:20:37 · 280 阅读 · 0 评论 -
php类成员函数中访问类外定义的变量
$public_var = "I am define out of any classes."; class testA{ public function printMsg($msg) { global $public_var; printf("public_var=%s\n",$pub原创 2012-11-26 13:44:42 · 1384 阅读 · 0 评论 -
execl函数 ,errcode:14,errstr:Bad address
是因为i_ret = execl("/bin/sh","sh","-x",str_script.c_str(),str_parameter.c_str());最后少一个参数,execl的最后一个参数必须是NULL改成i_ret = execl("/bin/sh","sh","-x",str_script.c_str(),str_parameter.c_str(),NULL); OK原创 2012-04-19 13:40:22 · 738 阅读 · 0 评论 -
日志不仅是代码中的一部分,而且是代码中最重要的部分
日志不仅是代码中的一部分,而且是代码中最重要的部分在写代码前先制订好日志规范。原创 2012-05-03 12:48:39 · 256 阅读 · 0 评论 -
setenv,getenv,mktime非线程安全函数,在多线程环境中使用要加锁
测试程序pthread_mutex_t st_lock;void* test_thd_func(void *p_arg){ pthread_detach(pthread_self()); char ac_name[1024] = {}; for (int i = 0; i { sprintf(ac_name,"st原创 2012-02-14 15:47:44 · 1943 阅读 · 1 评论 -
Linux文件系统操作函数
1.遍历目录下的所有文件及子目录opendir,参数是char*类型的目录全路径名,返回DIR结构体readdir把DIR结果作为参数,其反回值是指向目录中的下一个文件的dentry指针,struct dirent类型的.while在循环中调用readdir碰到null返回,即可以完成对目录的遍历.2.创建目录mkdir3.创建文件open(pa原创 2011-12-13 17:22:01 · 274 阅读 · 0 评论 -
静态链接和动态链接时常遇到的现象描述及问题解答
1.现象描述及问题解答g++ -L/home/me/lib/lib -lcppunit fw_test.o -o fw_test (1)如果在/home/me/lib/lib目录下同时存在libcppunit.so和libcppunit.a的话 这条编译命令将会链接libcppunit.so这个动态链接库(因为gcc/g++中动态链接库优先链接).(2)如果想指定链接静态链接库可以用原创 2011-12-10 13:32:11 · 612 阅读 · 0 评论 -
awk脚本的执行方式
方式1:命令行执行 命令行程序:awk [options] 'prog' [var=value] [file(s)] 如果没有指定file(s),则表示从终端读取输入。 例如awk -F'\t' 'BEGIN{a=1;b=2}{print a,b;}END{print a+b}' data_file方式2:shell脚本的形式也可以把上述代码放到脚本文件中(当作shel原创 2013-05-03 15:20:56 · 361 阅读 · 0 评论