ccufl , c common use function library,contain some frequently use function. eg :hashtable,linklist,array and so on.
一个简单的通用c函数库,在工作中经常使用的。
下面来说一说编译,安装和使用
下面就开始linxu下的源码编译三部曲。哦,是二部曲,没有configure这一步了。
make
make install
编译完成以后就会生成库文件 libccufl.a 和 libccufl.so
libccufl.a 是静态库文件
libccufl.so是动态库文件
使用的时候就可以链接了。 -lccufl
下面是一个简单的example例子
a hello.c example
#include <stdio.h>
#include "slist.h"
typedef struct node_t {
int num;
struct node_t * next;
}node;
void print(void*data){
printf("the node num:%d\n",((node*)data)->num);
}
int main(int argc,char * argv[]){
slist_t * slist=NULL;
node* n1=(node*)malloc(sizeof(node));
node* n2=(node*)malloc(sizeof(node));
n1->num=11;
n1->next=NULL;
n2->num=22;
n2->next=NULL;
slist=slist_create(sizeof(node),NULL,NULL);
slist_init(slist);
slist_append(slist,n1);
slist_append(slist,n2);
slist_traverse(slist,print,0,slist_count(slist)-1);
slist_free(slist);
}
gcc hello.c -o hello -I/include_path -L/lib_path/ -lccufl
还有很多的例子,hashmap hashtable list queue array 等等,这里就不一一列举了,源码有例子,可以下载下来自己研究
有什么问题可以评论,或者邮件联系我,Email : 545751287@qq.com
-----------------------------------------------------------------------------------
源码我也已经放到github上了
github : https://github.com/prownd/ccufl