![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C
文章平均质量分 55
ForkForYou
天雨虽宽,不润无根之草。
佛缘虽广,不度无缘之人。
展开
-
双向链表操作
/********************************************************************************** Description: Simple doubly linked list implementation.*******************************************************************************/#ifndef __LIST_H__#define __LIST_H原创 2022-03-24 22:44:02 · 797 阅读 · 0 评论 -
Makefile中的wildcard patsubst
在Makefile规则中,通配符会被自动展开。但在变量的定义和函数引用时,通配符将失效。这种情况下如果需要通配符有效,就需要使用函数“wildcard”,它的用法是:$(wildcard PATTERN…) 。在Makefile中,它被展开为已经存在的、使用空格分开的、匹配此模式的所有文件列表。如果不存在任何符合此模式的文件,函数会忽略模式字符并返回空。需要注意的是:这种情况下规则中通配符的展开和上一小节匹配通配符的区别。一般我们可以使用 “$(wildcard *.c)“来获取工作目录下的所有的.c文件原创 2022-03-18 11:06:14 · 302 阅读 · 0 评论 -
进度条C实现
#include <stdio.h>#include <string.h>#include <unistd.h>/* display by dynamic line * percent: range must at 0~100 */void update_progress_dynamic(int percent){ char str[] = {'-', '\\', '|', '/'}; printf("%c %3d%%\r", str原创 2021-03-16 15:21:21 · 146 阅读 · 0 评论 -
端口检测C程序
#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include <unistd.h>#include <sys/time.h>#include &l原创 2021-03-16 15:19:10 · 403 阅读 · 0 评论 -
TCP状态迁移
客户端TCP状态迁移:CLOSED->SYN_SENT->ESTABLISHED->FIN_WAIT_1->FIN_WAIT_2->TIME_WAIT->CLOSED服务器TCP状态迁移:CLOSED->LISTEN->SYN_RCVD->ESTABLISHED->CLOSE_WAIT->LAST_ACK->CLOSED原创 2021-02-25 11:18:39 · 224 阅读 · 0 评论 -
交叉编译
1. 本地编译在当前平台下,直接编译出来的程序,可以放到当前平台下运行。2. 交叉编译在当前平台下,编译出来的程序,可以放到另一平台下运行。3. 为什么要交叉编译主要是因为嵌入式系统中的资源太少,很难进行直接本地编译。编译开发需要较多的CPU,内存,硬盘等,而嵌入式开发上的资源,只够嵌入式系统运行的,没有足够的资源供本地编译。...原创 2021-01-28 16:11:38 · 73 阅读 · 0 评论 -
GCC 编译、静态库、动态库
1. gcc 编译工作流程 预处理(cpp) 编译器(gcc) 汇编器(as) 链接器(ld) gcc -E C文件 gcc -S 汇编文件 gcc -c 二进制文件 gcctest.c ------------> test.i ------------> test.s ------------> test.o -------------->原创 2020-11-26 13:40:24 · 152 阅读 · 0 评论 -
GCC 选项 “-Wl,-rpath=“
1. 介绍-Wl,-rpath=<your_lib_dir> 为程序添加一个运行时库文件搜索路径。-Wl:这个是gcc的参数,表示编译器将后面的参数传递给链接器 ld。-rpath:添加一个文件夹作为运行时库的搜索路径。在运行链接时,优先搜索-rpath路径,再去搜索LD_RUN_PATH路径。例如:# 指定链接的位置 $(prefix)/lib。程序运行时会先去$(prefix)/lib下搜索所需库文件。gcc -o foo foo.c -L$(prefix)/lib -lfo原创 2020-11-18 14:09:17 · 1154 阅读 · 0 评论 -
Makefile 中 := ?= += = 区别
Makefile 中 := ?= += = 区别 = 是最基本的赋值:= 是覆盖之前的值?= 是如果没有被赋值过就赋予等号后面的值+= 是添加等号后面的值 1. "=" make会将整个makefile展开后,再决定变量的值。也就是说,变量的值将会是整个makefile中最后被指定的值。看例子: x = foo y = $(x) bar x = xyz 在上例中,y的值将会是 xyz bar ,而不是 foo b原创 2020-07-16 17:32:07 · 229 阅读 · 1 评论 -
C 语言实现 trimspace
1. 函数 char *trimspace(char *str)#include <stdio.h>#include <string.h>#include <ctype.h>char *trimspace(char *str){ char *p = NULL; if (!str || *str == '\0') { return str; } // tirm prefix p = str; w原创 2020-11-25 11:28:47 · 385 阅读 · 0 评论 -
inline
inline函数1. 实现在 .h 中,未标记inline每一个包含该头文件的源文件都将得到一份关于该函数的定义,链接器会报函数重定义错误2. 实现在 .h 中,且标记inline每一个包含该头文件的源文件都将得到一份关于该函数的定义,但是链接器不会报错3. 实现在 .c 中,未标记inline该函数可以被连接到其他编译单元中4. 实现在 .c 中,且标记inline该函数对其他编译单元不可见(类似于static),其他源文件不能链接该函数库当连接到该库的时候会出现 undefine原创 2020-07-15 11:32:52 · 100 阅读 · 0 评论 -
程序段错误处理
概念: SIGSEGVSIGSEGV --- Segment Fault. The possible cases of your encountering this error are:buffer overflow --- usually caused by a pointer reference out of range.stack overflow --- please keep in mind that the default stack size is 8192K.illegal file原创 2020-07-14 09:43:09 · 1595 阅读 · 0 评论