Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Makefile shell调用中的哈希会导致意外行为 下面的命令打印一个特定C++头的绝对路径,根据G++认为它是在哪里。 echo \#include\<ham/hamsterdb.h\> | g++ -M -x c++-header - | grep hamsterdb.hpp | sed -e 's/-: //' -e 's/ \\//'_Shell_G++_Makefile_Echo - Fatal编程技术网

Makefile shell调用中的哈希会导致意外行为 下面的命令打印一个特定C++头的绝对路径,根据G++认为它是在哪里。 echo \#include\<ham/hamsterdb.h\> | g++ -M -x c++-header - | grep hamsterdb.hpp | sed -e 's/-: //' -e 's/ \\//'

Makefile shell调用中的哈希会导致意外行为 下面的命令打印一个特定C++头的绝对路径,根据G++认为它是在哪里。 echo \#include\<ham/hamsterdb.h\> | g++ -M -x c++-header - | grep hamsterdb.hpp | sed -e 's/-: //' -e 's/ \\//',shell,g++,makefile,echo,Shell,G++,Makefile,Echo,这将输出一个新行。我认为是hash(“#”)字符在搅乱make;如果我像这样重写文件=…行: FILE=$(shell echo \#include\<ham/hamsterdb.h\>) FILE=$(shell echo\#include\) 输出仍然是空的。您只需要再引用一点: FILE=$(shell echo \\\#include\<ham/hamsterdb.h\> ... ^^^ FILE=$(shell echo

这将输出一个新行。我认为是hash(“#”)字符在搅乱make;如果我像这样重写
文件=…
行:

FILE=$(shell echo \#include\<ham/hamsterdb.h\>)
FILE=$(shell echo\#include\)

输出仍然是空的。

您只需要再引用一点:

FILE=$(shell echo \\\#include\<ham/hamsterdb.h\> ...
                  ^^^
FILE=$(shell echo\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\包含\。。。
^^^

make
本身引用一次,为shell引用第二次(shell需要“查看”
\\\\
)。

为了在函数中使用哈希,必须两次转义:一次用于make,一次用于shell

就是

FILE = $(shell echo \\\#include\ \<ham/hamsterdb.h\>)
FILE = $(shell echo \\\#include\ \<ham/hamsterdb.h\>)
FILE = $(shell echo '\#include <ham/hamsterdb.h>')