摘要: 相关函数 mmap可以将文件映射在一段内存中,对该段内存的修改,将可以改变文件的内容。这一特性比较适合用于结构化文件的在位编辑工作。例如,以前修改配置程序,一个很low的办法是先读取文件的内容,如果是不需要修改的地方,就直接复制到另外一个文件中去,如果是需要修改的地方,就修改以后再写入到另一个文件中 阅读全文
posted @ 2021-02-02 20:05 castor_xu 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 1.结构体定义 timeval结构体在头文件为sys/time.h中,定义如下: struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ }; 该结构体以1970-01-01 00:0 阅读全文
posted @ 2021-01-18 15:41 castor_xu 阅读(17842) 评论(0) 推荐(0) 编辑
摘要: 有两个比较常用的函数,分别是strerror和perror。 strerror 头文件是string.h,原型为: char *strerror(int errnum); 接受一个表示错误代码的整型值,返回错误代码对应的信息字符串; perror 头文件是stdio.h,原型为: void perr 阅读全文
posted @ 2021-01-12 19:44 castor_xu 阅读(464) 评论(0) 推荐(0) 编辑
摘要: 基本函数和关系 pthread_create创建一个子线程; pthread_exit是线程函数在终止执行时调用,就像进程在执行完毕以后调用exit函数一样; pthread_join制定了主进程将要等待的子进程,该函数将阻塞主进程执行,直到子进程执行完毕,类似于wait函数。 测试代码(参考《Li 阅读全文
posted @ 2021-01-09 15:35 castor_xu 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 大概出现这样的常规操作是这样的:自定义了一个消息,然后用某个节点发布了该消息的topic,接下来是使用rostopic去list,正常,然后去使用rostopic echo就报错了,见下图: 其实这个问题和很多常见的问题一样,处理方式是要source一下./devel/setup.bash,见下图: 阅读全文
posted @ 2020-10-02 23:04 castor_xu 阅读(3002) 评论(0) 推荐(0) 编辑
摘要: 在使用newtonSoft的Json做读取json配置文件信息时,发现会出现中文乱码,出现一堆的问号: using Newtonsoft.Json; using System; using System.IO; using System.Text; namespace CSJsonTest { cl 阅读全文
posted @ 2020-09-05 16:17 castor_xu 阅读(1067) 评论(0) 推荐(0) 编辑
摘要: C 语言中assert.h头文件唯一的目的就是提供了assert宏的定义,这个被称为断言,断言的效果是,如果断言的内容为真,断言就没有任何意义,如果断言为假,程序将执行异常终止。 测试代码: #include <stdio.h> #include <assert.h> int main(int ar 阅读全文
posted @ 2020-08-28 23:32 castor_xu 阅读(202) 评论(0) 推荐(0) 编辑
摘要: #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <pthread.h> #include <sys/stat.h> #include <time.h> void PTS(ti 阅读全文
posted @ 2020-08-13 22:56 castor_xu 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 这个函数是设置一个定时器,在接下来的某个时刻该定时器会超时,发生超时后,产生SIGALRM信号。 产生信号后,进程的行为分两种情况: 1. 忽略或者不捕获此信号 终止调用该alarm函数的进程 2. 捕获此信号 根据信号处理程序采取动作 测试代码: 1 #include <signal.h> 2 # 阅读全文
posted @ 2020-05-21 23:02 castor_xu 阅读(418) 评论(0) 推荐(0) 编辑
摘要: 看手册: The <pwd.h> header shall provide a definition for struct passwd, which shall include at least the following members: char *pw_name User's login n 阅读全文
posted @ 2020-05-19 20:09 castor_xu 阅读(1300) 评论(0) 推荐(0) 编辑