小编cas*_*mia的帖子

为什么在 Linux 中使用“ln -sf”?

我有2个问题。第一个用于-sf选项,第二个用于更具体的-f选项用法。

通过谷歌搜索,我找到了 command ln、 option-s和-f.

(从http://linux.about.com/od/commands/l/blcmdl1_ln.htm复制)

-s, --symbolic : make symbolic links instead of hard links
-f, --force : remove existing destination files
Run Code Online (Sandbox Code Playgroud)

我分别理解这些选项。但是,如何同时使用 this-s和-foptions 呢?-s用于创建链接文件,-f用于删除链接文件。为什么要使用这个合并选项?

为了更多地了解ln命令,我做了一些例子。

$ touch foo     # create sample file
$ ln -s foo bar # make link to file
$ vim bar       # check how link file works: foo file opened
$ ln -f …
Run Code Online (Sandbox Code Playgroud)

shell ln

28
推荐指数
1
解决办法
3万
查看次数

为什么在 Linux 上的“time.h”中定义了“timer_t”而不是 OS X

当我阅读 C 源代码文件时,我发现了这个声明。(此源码是为linux系统程序编写的,这是很重要的信息)

#include <time.h>
#include <stdio.h>

static timer_t* _interval_timer;
...
Run Code Online (Sandbox Code Playgroud)

起初,我想更多地了解“timer_t”。所以我用谷歌搜索“time.h”来获取标题信息。但是,没有任何关于'timer_t'的词,只提到了'time_t'。

出于好奇,我在我的 'mac' 计算机中搜索并打开了 'time.h' c 标准库文件(如您所知,/usr/include 文件夹存储 c 标准库文件。)但该文件与之前在 google 上搜索到的文件相同。

最后,我使用虚拟机打开我的linux os(ubuntu)并打开linux c标准库文件夹中的'time.h'(文件夹路径与OSX相同)。正如我所料,Linux 中的“time.h”文件声明了 timer_t。

我在下面添加了声明“timer_t”类型的代码行。

#if !defined __timer_t_defined && \
((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timer_t)
# define __timer_t_defined      1

# include <bits/types.h>

/* Timer ID returned by `timer_create'.  */
typedef __timer_t timer_t;
Run Code Online (Sandbox Code Playgroud)

我的问题是这个。

  1. 为什么 'timer_t' 只在 linux c 标准库中定义?

  2. 这种情况经常发生吗?我的意思是,不同操作系统之间是否有任何不同定义的功能或属性?

linux c darwin

13
推荐指数
1
解决办法
7938
查看次数

标签 统计

c ×1

darwin ×1

linux ×1

ln ×1

shell ×1