【问题标题】:Error using hashlib++ in c++ builder?在 C++ 构建器中使用 hashlib++ 时出错?
【发布时间】:2011-06-16 11:18:36
【问题描述】:

我下载了最新的 hashlib++ 0.32 版本并尝试使用哈希函数,但它显示 Unsupported compiler。

[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) 编译器中工作?

【问题讨论】:

    标签: c++ encryption hash c++builder


    【解决方案1】:

    我认为错误消息几乎说明了该怎么做...将以下内容添加到_MSC_VER检查下方和最终#else上方的头文件中:

    #elif defined( __BORLANDC__ )
    typedef unsigned __int64 hl_uint64;
    

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

    【讨论】:

    • 我在 hl_types #elif defined( BORLANDC ) typedef unsigned __int64 hl_uint64; 中添加了以下几行
    【解决方案2】:

    “不支持的编译器”错误来自以下代码部分:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多