【问题标题】:Print all code listings from a C++ project打印 C++ 项目中的所有代码清单
【发布时间】:2012-02-05 10:06:50
【问题描述】:

我需要打印一个由一堆 .h 和 .cpp 文件组成的项目的源代码(我需要将它交给我的老师)。是否有 IDE 或程序可让您一次打印(或导出为 PDF 或 Latex)所有文件,并可能保持语法突出显示?我尝试使用 XCode 和 Visual Studio,但它们只允许一次打印一个文件。

【问题讨论】:

  • 看看stackoverflow.com/questions/683759/… 看看是否有帮助。
  • Pretty Code Printing 说项目文件不受支持(显然它不适用于 C++ 代码)。至于宏,我在 projitem.Document.PrintOut() 处得到 E_FAIL COMException

标签: c++ printing ide


【解决方案1】:

a2psenscript 这样的GNU 工具可以将源代码转换为postscript 文件,然后您可以打印或转换为pdf。它们支持各种语言的语法高亮显示,并且可以将多个文件捆绑到同一个文档中。

【讨论】:

  • a2ps 真的是一个很棒的工具!它完全符合我的需要!非常感谢!
【解决方案2】:

你可以试试linux盒子:

grep '#include <' *.{hpp,h,cpp,c} | uniq > output.cpp
grep -v '#include' *.{hpp,h} >> output.cpp # This line may cause problem if .h relies on each other and you maybe will have to list files manually
grep -v '#include' *.{cpp,c} >> output.cpp

然后在支持导出高亮代码(vim、gedit...)的编辑器中打开 output.cpp 或将其粘贴到诸如 pastebin 之类的门户上:P

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-24
    • 2012-12-11
    • 2020-03-23
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多