简体   繁体   English

为什么不 <string.h> 在getopt库中?

[英]Why no <string.h> in getopt library?

I have been using Ludvig Jerabek's port of the GNU getopt on Windows and getting errors on lines like: 我一直在Windows上使用Ludvig Jerabek的GNU getopt的端口,并在诸如以下的行中获取错误:

if (d->optind != argc && !_tcscmp(argv[d->optind], _T("--")))

_tcscmp is a macro that resolves to strcmp on my system and then it reports strcmp not found. _tcscmp是一个宏,它解析为我系统上的strcmp ,然后报告未找到strcmp If we examine the headers in getopt.cpp: 如果我们检查getopt.cpp中的标题:

/* 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"

We see the problem: <string.h> is not included. 我们看到了问题:不包含<string.h> I guess in Visual Studio <string.h> is included automatically maybe? 我猜Visual Studio <string.h>是否自动包含在内? I know I have successfully built getopt.cpp in Visual Studio, but using a manual environment with gcc on MinGW it is complaining about all the string compare functions being missing. 我知道我已经在Visual Studio中成功构建了getopt.cpp,但是在MinGW上使用带有gcc的手动环境时,它抱怨缺少所有字符串比较功能。 What is the explanation for this? 这有什么解释?

The real tchar.h causes either #include <string.h> or #include <mbstring.h> depending on the character-set macros. 真正的tchar.h会导致#include <string.h>#include <mbstring.h>具体取决于字符集宏。

You have a broken version of tchar.h that does not correctly emulate these Microsoft-specific "Generic-Text Routine Mappings". 您有一个tchar.h损坏的版本,它不能正确地模拟这些Microsoft特定的“通用文本例程映射”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM