windows VC++ 中的 getopt()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/543570/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:57:50  来源:igfitidea点击:

getopt() in VC++

c++windowsvisual-studio-2008

提问by Aaron

I'm quite fond of using GNU getopt, when programming under Linux. I understand, that getopt(), is not available under MS VC++.

Linux下编程时,我非常喜欢使用 GNU getopt。我知道,getopt() 在 MS VC++ 下不可用。

Note:

笔记:

  • Win32 environment
  • using Visual Studio
  • No Boost
  • No MFC
  • Not concerned with portability
  • Win32环境
  • 使用 Visual Studio
  • 没有提升
  • 没有 MFC
  • 不关心便携性

Question:

题:

  • How can I then port getopt() accordingly?
    • What guidelines should I be aware of while porting?
  • Known port with samefeatures?
  • 我怎样才能相应地移植 getopt() ?
    • 移植时我应该注意哪些准则?
  • 具有相同功能的已知端口?

采纳答案by Harold Bamford

You will have to check out the license requirements, but the source to the GCC libraries is freely available. Just grab getopt() from there.

您必须查看许可要求,但 GCC 库的源代码是免费提供的。只需从那里获取 getopt() 即可。

回答by Andrew Grant

This may help, it's also very easy to integrate

这可能会有所帮助,它也很容易集成

http://www.codeproject.com/KB/cpp/xgetopt.aspx

http://www.codeproject.com/KB/cpp/xgetopt.aspx

回答by Bob Prystanek

There is some old code originally by IBM that is available as-is. It only has implementation for getopt, not the _long variants. It's available on http://plexfx.org/news/files/70411c2c371bd686273a8bebc42c45c5-3.html

有一些由 IBM 原创的旧代码可以按原样使用。它只有 getopt 的实现,而不是 _long 变体。它可以在http://plexfx.org/news/files/70411c2c371bd686273a8bebc42c45c5-3.html 上找到