繁体   English   中英

等价于gnu中来自Windows stdint.h的u_int16_t?

[英]Equivalent of u_int16_t from windows stdint.h in gnu?

到目前为止,我假设u_int16_t是一个名为stdint.h的MSVS头文件内部的Windows类型。 我正在使用GNU g ++作为编译器(实际上是带有mingw的代码块),我想知道typedef unsigned short uint_least16_t; (在mingw的stdint.h内部)是等效的还是可以做些什么来包括这种类型?

这个问题实际上与编译用于MSVS的google sparsehash项目文件有关,但是我正在使用代码块。 这就是它给我的错误(顺便说一句,该错误重复了很多次)。

c:\\program files\\codeblocks\\mingw\\bin\\..\\lib\\gcc\\mingw32\\4.4.1\\..\\..\\..\\..\\include\\sparsehash\\sparsetable|40|error: 'u_int16_t' does not name a type|

继承人的完整日志多达50个错误。

||=== simple_test, Debug Win32 ===|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|40|error: 'u_int16_t' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|563|error: 'u_int16_t' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|582|error: 'u_int16_t' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|637|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|638|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|639|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|640|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|641|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|643|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|665|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|698|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|708|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|717|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|742|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|798|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|799|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|802|error: 'size_type' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|807|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|817|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|823|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|831|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|835|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|847|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|857|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|871|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|895|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|910|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|924|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|939|error: 'size_type' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|1093|error: 'u_int16_t' has not been declared|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|1098|error: 'u_int16_t' does not name a type|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable||In member function 'google::table_iterator<google::sparsegroup<T, GROUP_SIZE, Alloc> > google::sparsegroup<T, GROUP_SIZE, Alloc>::end()':|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|597|error: there are no arguments to 'size' that depend on a template parameter, so a declaration of 'size' must be available|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|597|note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable||In member function 'google::const_table_iterator<google::sparsegroup<T, GROUP_SIZE, Alloc> > google::sparsegroup<T, GROUP_SIZE, Alloc>::end() const':|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|598|error: there are no arguments to 'size' that depend on a template parameter, so a declaration of 'size' must be available|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable||In member function 'int google::sparsegroup<T, GROUP_SIZE, Alloc>::bmtest(int) const':|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|639|error: there are no arguments to 'charbit' that depend on a template parameter, so a declaration of 'charbit' must be available|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|639|error: there are no arguments to 'modbit' that depend on a template parameter, so a declaration of 'modbit' must be available|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable||In member function 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::bmset(int)':|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|640|error: there are no arguments to 'charbit' that depend on a template parameter, so a declaration of 'charbit' must be available|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|640|error: there are no arguments to 'modbit' that depend on a template parameter, so a declaration of 'modbit' must be available|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable||In member function 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::bmclear(int)':|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|641|error: there are no arguments to 'charbit' that depend on a template parameter, so a declaration of 'charbit' must be available|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|641|error: there are no arguments to 'modbit' that depend on a template parameter, so a declaration of 'modbit' must be available|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable||In member function 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::set_aux(int, google::true_type)':|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|851|error: 'size_type' was not declared in this scope|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|851|error: expected ';' before 'i'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|851|error: 'i' was not declared in this scope|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable||In member function 'typename Alloc::rebind<T>::other::reference google::sparsegroup<T, GROUP_SIZE, Alloc>::set(int, typename Alloc::rebind<T>::other::const_reference)':|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|872|error: 'size_type' was not declared in this scope|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|872|error: expected ';' before 'offset'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|875|error: 'offset' was not declared in this scope|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|884|error: 'offset' was not declared in this scope|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|890|error: 'offset' was not declared in this scope|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable||In member function 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::erase_aux(int, google::true_type)':|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|917|error: 'size_type' was not declared in this scope|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|917|error: expected ';' before 'i'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\sparsehash\sparsetable|917|error: 'i' was not declared in this scope|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|

如果没有任何定义u_int16_t标头。 自己做 :

#include <stdint.h>
#include <stddef.h>

typedef uint16_t u_int16_t;
typedef size_t size_type;

我不确定如何指定u_int16_t 如您所知,这是非标准的。 您应该使用什么取决于您想要的:

uint16_t        //  Exactly 16 bits, only present if the hardware
                //  has such a type.
uint_least16_t  //  The smallest type which has at least 16 bits.
uint_fast16_t   //  The fastest type which has at least 16 bits.

在大多数现代机器上,这三个机器都是相同类型的typedef,通常是unsigned short ,我经常在“便携式”代码中使用uint16_t ,因为这是最容易编写的程序,也是我遇到机器的机会。定义非常非常苗条。 (唯一不被定义的现代机器是Unisys大型机和某些具有32位字节的嵌入式处理器。)

关于size_type ,这可能是 size_t <stddef.h><cstddef> (它是std::size_t )中,而不是在<stdint.h>

您应该运行./configure脚本。 不幸的是,这在Windows上可能是一个真正的痛苦,因此项目的src/windows目录中具有./configure为VC ++生成的标头。 这就是u_int16_t适用于VC ++的原因-它不在任何VC ++头文件中,但是config.hsparseconfig.h文件会处理它。

不幸的是,VC ++配置不适用于MinGW。 理想情况下,您将能够为MinGW运行./configure ,但是正如我提到的那样,在Windows上可能很难。 这是一个config.h文件,它使我能够编译项目的simple_test.cc程序。 需要对spareseconfig.h进行相应的更改。 此外,对于较大的项目使用范围,或者如果您使用不同版本的MinGW(例如,MinGW 4.7+应该使用<unordered_map>而不是<ext/hash_map> ),可能需要进行不同的调整:

#ifndef GOOGLE_SPARSEHASH_WINDOWS_CONFIG_H_
#define GOOGLE_SPARSEHASH_WINDOWS_CONFIG_H_

/* src/config.h.in.  Generated from configure.ac by autoheader.  */

/* Namespace for Google classes */
#define GOOGLE_NAMESPACE  ::google

/* the location of the header defining hash functions */
#define HASH_FUN_H  <ext/hash_map>

/* the location of <unordered_map> or <hash_map> */
#define HASH_MAP_H  <ext/hash_map>

/* the namespace of the hash<> function */
#define HASH_NAMESPACE  __gnu_cxx

/* the location of <unordered_set> or <hash_set> */
#define HASH_SET_H  <hash_set>

/* Define to 1 if you have the <google/malloc_extension.h> header file. */
#undef HAVE_GOOGLE_MALLOC_EXTENSION_H

/* define if the compiler has hash_map */
#define HAVE_HASH_MAP  1

/* define if the compiler has hash_set */
#define HAVE_HASH_SET  1

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if the system has the type `long long'. */
#define HAVE_LONG_LONG  1

/* Define to 1 if you have the `memcpy' function. */
#define HAVE_MEMCPY  1

/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE  1

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* define if the compiler implements namespaces */
#define HAVE_NAMESPACES  1

/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H  1

/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H  1

/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H  1

/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H  1

/* Define to 1 if you have the <sys/utsname.h> header file. */
#undef HAVE_SYS_UTSNAME_H

/* Define to 1 if the system has the type `uint16_t'. */
#undef HAVE_UINT16_T

/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

/* define if the compiler supports unordered_{map,set} */
#undef HAVE_UNORDERED_MAP

/* Define to 1 if the system has the type `u_int16_t'. */
#undef HAVE_U_INT16_T

/* Define to 1 if the system has the type `__uint16'. */
#define HAVE___UINT16  1

/* Name of package */
#undef PACKAGE

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

/* Define to the full name of this package. */
#undef PACKAGE_NAME

/* Define to the full name and version of this package. */
#undef PACKAGE_STRING

/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME

/* Define to the home page for this package. */
#undef PACKAGE_URL

/* Define to the version of this package. */
#undef PACKAGE_VERSION

/* Define to necessary symbol if this constant uses a non-standard name on
   your system. */
#undef PTHREAD_CREATE_JOINABLE

/* The system-provided hash function including the namespace. */
#define SPARSEHASH_HASH  HASH_NAMESPACE::hash

/* The system-provided hash function, in namespace HASH_NAMESPACE. */
#define SPARSEHASH_HASH_NO_NAMESPACE  hash

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS  1

/* Version number of package */
#undef VERSION

/* Stops putting the code inside the Google namespace */
#define _END_GOOGLE_NAMESPACE_  }

/* Puts following code inside the Google namespace */
#define _START_GOOGLE_NAMESPACE_   namespace google {


// ---------------------------------------------------------------------
// Extra stuff not found in config.h.in

#define HAVE_WINDOWS_H  1   // used in time_hash_map

// This makes sure the definitions in config.h and sparseconfig.h match
// up.  If they don't, the compiler will complain about redefinition.
#include <sparsehash/internal/sparseconfig.h>

// TODO(csilvers): include windows/port.h in every relevant source file instead?
//#include "windows/port.h"

#endif  /* GOOGLE_SPARSEHASH_WINDOWS_CONFIG_H_ */

暂无
暂无

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

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