<image>.h - 这个 -e 从哪里来?

<image>.h - Where is this -e coming from?

本文关键字:lt image gt 这个      更新时间:2023-10-16

当我尝试构建这个项目时,我得到以下问题:

drazisil@Lightning:~/comical$ make -C src
make: Entering directory '/home/drazisil/comical/src'
Converting firstpage.png
...
make[1]: Entering directory `/home/travis/build/drazisil/comical/src'
`wx-config --cxx` `wx-config --cxxflags` -O2 -Wall -pipe -D_UNIX -I../unrar -I../unzip -c -o ComicalApp.o ComicalApp.cpp
In file included from ComicalFrame.h:43:0,
                 from ComicalManager.h:32,
                 from ComicalApp.h:32,
                 from ComicalApp.cpp:28:
firstpage.h:2:1: error: stray ‘#’ in program
原因似乎是因为在生成的。h文件的开头和结尾都插入了一个-e:
#ifndef _firstpage_png_h
-e #define _firstpage_png_h
static const unsigned char firstpage_png[] = {
...
...
...
-e };
#endif

因为我不确定这个过程的哪个步骤是导致这个,我不确定如何删除它,或者它甚至意味着什么。搜索-e的效果不太好。

ETA: Makefile: https://github.com/drazisil/comical/blob/dev/Makefile

我该如何修复它?

问题是src/Makefile文件中的这个目标。

%.h : %.png
    @echo "Converting" $<
    @echo "#ifndef _"$*"_png_h" > $@
    @echo -e "#define _"$*"_png_hn" >> $@
    @echo "static const unsigned char "$*"_png[] = {" >> $@
    @hexdump -e "13/1 "0x%02X, " "n"" $< | sed 's/0x  ,//g' >> $@
    @echo -e "};nn#endif" >> $@

具体来说,这两行使用echo -e,试图在回显输出的末尾放置一个额外的换行符。

echo -e,然而,是非标准的,你的shell/版本的echo显然不理解它。

如果将这些行重写为

,效果会更好。
@printf '#define _$*_png_hnn' >> $@
@printf '};nn#endifn' >> $@

对该目标的其他改进也是可能的,但超出了此问题的范围(主要是使用单个shell命令和单个重定向而不是五个)。