英文:
How do I access the cppfront executable's help doc?
问题
我尝试运行 cppfront --help,并得到以下输出:
--help...
--help: error: source filename must end with .cpp2 or .h2: --help
我期望使用 --help 会导致 cppfront 可执行文件打印其帮助信息/文档字符串。 --help 是一个相当常见的标志/参数,用于此目的。
英文:
I tried running cppfront --help, and got the following output:
--help...
--help: error: source filename must end with .cpp2 or .h2: --help
I expected using --help to cause the cppfront executable to print its help message / doc string. --help is a pretty conventional flag / argument for that purpose.
答案1
得分: 1
以下是您要翻译的内容:
正确的标志以获取cppfront打印其帮助文档是-help(一个短划线而不是两个)。您也可以使用-?。标志也可以以/而不是-为前导。
一旦您知道了这一点并打印了帮助字符串,您将看到cppfront不遵循使用两个短划线作为长格式命令行参数/标志的相对常见模式,而是对所有内容都使用单个前导短划线。我想这符合许多GCC的参数/标志的规律,但即使是GCC也对--help使用了两个短划线,而没有-help。
在编写本文时,打印帮助消息的源代码可以在source/common.h(print_help函数)中找到。
如果您以无参数运行cppfront,它实际上会显示以下内容:
cppfront: error: no input files (try -help)
cppfront中还有一行代码,如果您传递一个需要值的参数但不传递值,它将打印一个引用-help的消息:
print("Missing argument to option " + arg->text + " (try -help)\n");
英文:
The correct flag to use to get cppfront to print its help doc is -help (one leading dash instead of two). You can also use -?. And flags can be led with / instead of - too.
Once you know that and print the help string, you'll see that cppfront doesn't follow the relatively common pattern of using two dashes for long-form commandline arguments / flags, and instead uses a single leading dash for everything. I suppose that's in line with a lot of GCC's arguments / flags, but even GCC uses two dashes for --help and has no -help.
The source code for printing the help message can (at the time of this writing) be found in source/common.h (the print_help function).
If you run cppfront with no arguments, it'll actually say the following:
cppfront: error: no input files (try -help)
There's also a line of code in cppfront that will print a message referencing -help if you pass an argument that takes a value but don't pass a value:
print("Missing argument to option " + arg->text + " (try -help)\n");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论