- 一、linux线程
- (1)线程库
- 二、C语言
- (1)ifndef
- (2)short unsigned int 的scanf及printf格式
参考文献
linux中线程属于第三方库开发
安装线程库man手册:
sudo apt-get install manpages manpages-dev
sudo apt-get install manpages-posix-dev
编译:
gcc -o bin src.c -lpthread //指定线程库链接
如果不安装这个,man pthread_mutex_init 就没有条目。
二、C语言 (1)ifndef(2)short unsigned int 的scanf及printf格式标识的命名规则一般是头文件名全大写,前后加下划线,并把文件名中的“.”也变成下划线,如:stdio.h
#ifndef _STDIO_H_
#define _STDIO_H_…
#endif
参考文献1
For scanf, you need to use %hu since you’re passing a pointer to an
unsigned short. For printf, it’s impossible to pass an unsigned short
due to default promotions (it will be promoted to int or unsigned int
depending on whether int has at least as many value bits as unsigned
short or not) so %d or %u is fine. You’re free to use %hu if you
prefer, though.
参考文献2
对于printf
A format specifier follows this prototype:
%[flags][width][.precision][length]specifier
对于scanf
A format specifier for scanf follows this prototype:
%[*][width][length]specifier



