c - 为什么 getopt 库中没有 <string.h>?

标签 c windows gnu portability getopt

我一直在 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/

相关文章:

linux - 如何使用 GNU 并行运行命令列表,其中 4 个命令同时运行

c - 计算发生次数的有效方法

javascript - Windows 8 商店应用程序 : how to have the app live tile change constantly of colour (and text)?

C - 查找字符数组中出现频率最高的元素

windows - 如何在 Windows 8 (WinRT) 应用程序中显示可缩放图像?

c++ - Windows非ASCII文件路径

linux - sed 命令在 gitlab runner 上无法正确执行

c - hsearch_r 覆盖哈希表

c++ - "const"是如何实现的?

C : Dereferencing pointer to incomplete type error