linux - 查找字符串是否直接或间接存在于所有文件中

标签 linux shell unix

我有一组 c 文件,我需要找出一个特定的头文件是否直接或间接存在于所有文件中。

For ex:-
Header files:-

hf1.h:-
int i = 10;

hf2.h:-
#include "hf1.h"

hf3.h:-
#include <hf1.h>

hf4.h:-
#include <hf3.h>

c files:-
cf1.c:-
#include <hf1.h>

cf2.c:-
#include <hf2.h>

cf3.c:-
#include <hf4.h>

在这种情况下,hf4.h 间接包含 hf1.h 文件。我需要确定 hf1.h 是直接还是间接包含在所有文件中。让我知道是否有人需要更多说明。

解决此问题的任何 unix 命令或 shell 脚本。

最佳答案

  1. 在 hf1.h 中引入 #error 指令
  2. 清理
  3. make -k all
  4. 现在存在的所有目标文件都没有包含hf1.h

-k 步骤是关键步骤:它确保编译在第一个损坏的文件之后继续。

关于linux - 查找字符串是否直接或间接存在于所有文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7657372/

相关文章:

c# - Windows 终端 - 用于嵌入 cmd 的 Windows 窗体

bash - 使用 bash 提取数字并转换为 CSV 文件

c++ - 如何在 Linux 中从 Cirque 触摸板读取点击的绝对位置

linux - Sed 在新行后字符串 Linux 上插入字符串

c# - 在C#程序中访问linux文件系统

linux - linux将文件从usb复制到桌面脚本

linux - xargs bash -c 意外标记

linux - awk 自动舍入输出

c - 在术语中使用反引号打开时屏幕尺寸为 NULL

c - 如何在 C 中将数据包写入 TAP 接口(interface)?