c++ - <image>.h - 这个 -e 来自哪里?

标签 c++ makefile wxwidgets header-files

我在尝试构建此项目时遇到以下问题:

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 效果不佳。

提前感谢您的帮助。

预计到达时间:生成文件:https://github.com/drazisil/comical/blob/dev/Makefile

最佳答案

问题是this targetsrc/Makefile 文件中。

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

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

但是,

echo -e 是非标准的,您的 echo shell/版本显然无法理解它。

将这些行重写为该目标会更好:

@printf '#define _$*_png_h\n\n' >> $@
@printf '};\n\n#endif\n' >> $@

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

关于c++ - <image>.h - 这个 -e 来自哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33088744/

相关文章:

python - 将小部件关联到组中,用于隐藏和显示,wxpython

c++ - wxTextCtrl换行问题

c++ - 在Windows 10上使用wxWidgets(MinGW模式)编译源代码的问题

c++ - QGL小部件: Using setFormat() To Enable Multisampling = The Window Doesn't Close

c++ - OpenCV/Tesseract:如何用 GDI+ 位图替换 libpng、libtiff 等(通过 GDI+ 加载到 cv::Mat)

c - 递归所有 C 文件

makefile - Makefile中@符号的含义? (不是回声抑制,也不是自动变量)

c++ - 我可以在 Qt 中映射列表吗?

c++ - 如何隐式调用 C 风格的清洁函数?

makefile - 如何在Makefile中编写循环?