2011-01-27 105 views
2

我下载了最新的hashlib ++ 0.32版本,并试图使用散列函数,但它说不支持编译器。在C++ builder中使用hashlib ++时出错?

[BCC32 Fatal Error] hl_types.h(71): F1003 Error directive: "Unsuppported compiler."    "Please use GCC,MINGW,MSVC "   " or define hl_uint64 for your compiler in hl_types.h line 62" 

的hl_types.h看起来

/* 
* hashlib++ - a simple hash library for C++ 
* 
* Copyright (c) 2007-2010 Benjamin Grьdelbach 
* 
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met: 
* 
* 1)  Redistributions of source code must retain the above copyright 
*   notice, this list of conditions and the following disclaimer. 
* 
* 2)  Redistributions in binary form must reproduce the above copyright 
*   notice, this list of conditions and the following disclaimer in 
*   the documentation and/or other materials provided with the 
*   distribution. 
*  
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
*/ 

//----------------------------------------------------------------------  

/** 
* @file hl_types.h 
* @brief This file defines some global types 
* @date So 13 Jan 2008 
*/ 

//----------------------------------------------------------------------  
//include protection 
#ifndef HLTYPES_H 
#define HLTYPES_H 

//----------------------------------------------------------------------  

/** 
* exactly 1 Byte 
*/ 
typedef unsigned char hl_uint8; 

/** 
* at least 2 Byte 
*/ 
typedef unsigned short int hl_uint16; 

/** 
* at least 4 Byte 
*/ 
typedef unsigned int hl_uint32; 

/** 
* at least 8 Byte 
*/ 
#ifdef __GNUC__ 
    typedef unsigned long long int hl_uint64; 
#elif __MINGW32__ 
    typedef unsigned long long int hl_uint64; 
#elif _MSC_VER 
    typedef unsigned __int64 hl_uint64; 
#else 
    #error "Unsuppported compiler." \ 
       "Please use GCC,MINGW,MSVC " \ 
      " or define hl_uint64 for your compiler in hl_types.h line 62" 
#endif 


//----------------------------------------------------------------------  
//end of include protection 
#endif 

//----------------------------------------------------------------------  
//EOF 

我问有没有什么办法让它在Borland的C++ Builder的2010(BCC32)编译器的工作?

回答

4

我认为错误消息几乎说该怎么办...添加如下头文件下面_MSC_VER检查等的最终的#else:

#elif defined(__BORLANDC__) 
typedef unsigned __int64 hl_uint64; 

(生成器具有“__int64”扩展整型)

+0

添加以下line to hl_types #elif defined(__BORLANDC__) typedef unsigned __int64 hl_uint64; – 2011-01-28 03:23:16

0

“不支持编译”错误来自的代码表示的部分:

/** 
* at least 8 Byte 
*/ 
#ifdef __GNUC__ 
    typedef unsigned long long int hl_uint64; 
#elif __MINGW32__ 
    typedef unsigned long long int hl_uint64; 
#elif _MSC_VER 
    typedef unsigned __int64 hl_uint64; 
#else 
    #error "Unsuppported compiler." \ 
      "Please use GCC,MINGW,MSVC " \ 
     " or define hl_uint64 for your compiler in hl_types.h line 62" 
#endif 

你需要学会阅读错误消息,如果你打算做了很多节目。具体来说,该消息的部分表示“或在hl_types.h行62中为您的编译器定义hl_uint64”。您需要做的只是添加一行,用于标识该节中其他编译器的行中的64位整数类型。例如:

typedef unsigned long long hl_uint64; 

或者,如果Borland的,您可以访问stdint.h:

#include "stdint.h" 
typedef uint64_t hl_uint64;