我一直在 Windows 上使用 Ludvig Jerabek 的 GNU getopt 端口并在以下几行出现错误:
if (d->optind != argc && !_tcscmp(argv[d->optind], _T("--")))
_tcscmp
是解析为 strcmp
的宏在我的系统上,然后它报告 strcmp
未找到。如果我们检查 getopt.cpp 中的 header :
/* Getopt for Microsoft C
....
Date: 02/03/2011 - Ludvik Jerabek - Initial Release
....
Revisions:
....
08/09/2011
....
#include <stdlib.h>
#include <stdio.h>
#include "getopt.h"
我们看到问题:<string.h>
不包括在内。我猜在 Visual Studio 中 <string.h>
也许是自动包含的?我知道我已经在 Visual Studio 中成功构建了 getopt.cpp,但是在 MinGW 上使用带有 gcc 的手动环境时,它提示缺少所有字符串比较函数。对此有何解释?
最佳答案
真实tchar.h
导致 #include <string.h>
或 #include <mbstring.h>
取决于字符集宏。
您的 tchar.h
版本已损坏不能正确模拟这些 Microsoft 特定的“通用文本例程映射”。
关于c - 为什么 getopt 库中没有 <string.h>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29707382/