精华内容
下载资源
问答
  • 在不使用限制的情况下,将可区分性作为本地属性引入。 该课程是为具有微积分背景的生命科学专业设计的,他们的主要兴趣在于微积分的应用。
  • 基于Coq的不用极限微积分形式化验证,郭礼权,郁文生,人工智能是我国当前重大科技发展战略之一,数学形式化作为人工智能的重要理论基础,对科技发展具有重要意义. 本文基于证明辅助工�
  • } 使用cppcheck检查时会报错 (warning)sscanf() without field width limits can crash with huge input data. 解决办法 使用sscanf时在匹配规则里添加长度限制 将 sscanf(detail, "%[^-]-%[^-]-%s", ip, name, tel...

    该问题是cppcheck检测出使用sscanf函数时,开发人员未对匹配的字符串做长度限制导致的

    举个栗子

    #include <stdio.h>
    
    int main()
    {
        char ip[16] = {0};
        char name[32] = {0};
        char tel[12] = {0};
        char detail[400] = "172.16.117.121-Primeprime-18888888888";
        sscanf(detail, "%[^-]-%[^-]-%s", ip, name, tel);
        printf("ip:%s\tname:%s\ttel:%s\n", ip, name, tel);
        return 0;
    }

    使用cppcheck检查时会报错

    (warning)sscanf() without field width limits can crash with huge input data.

    解决办法

    使用sscanf时在匹配规则里添加长度限制

    将 sscanf(detail, "%[^-]-%[^-]-%s", ip, name, tel);

    改为 sscanf(detail, "%15[^-]-%31[^-]-%11s", ip, name, tel);

    #include <stdio.h>
    
    int main()
    {
        char ip[16] = {0};
        char name[32] = {0};
        char tel[12] = {0};
        char detail[400] = "172.16.117.121-Primeprime-18888888888";
        sscanf(detail, "%15[^-]-%31[^-]-%11s", ip, name, tel);
        printf("ip:%s\tname:%s\ttel:%s\n", ip, name, tel);
        return 0;
    }

    修改后使用cppcheck检查,没有warning了

    展开全文
  • std::numeric_limits使用

    千次阅读 2019-11-04 16:41:02
    std::numeric_limits std::numeric_limits 定义于头文件<limits> template<classT>classnumeric_limits; numeric_limits类模板提供查询各种...

    std::numeric_limits

    std::numeric_limits

    定义于头文件 <limits>

      
    template< class T > class numeric_limits;

     

      
       

    numeric_limits 类模板提供查询各种算术类型属性的标准化方式(例如 int 类型的最大可能值是 std::numeric_limits<int>::max() )。

    通过 numeric_limits 模板的特化提供此信息。标准库为所有算术类型制定可用的特化:

    定义于头文件 <limits>

      
    template<> class numeric_limits<bool>;
    template<> class numeric_limits<char>;
    template<> class numeric_limits<signed char>;
    template<> class numeric_limits<unsigned char>;
    template<> class numeric_limits<wchar_t>;
    template<> class numeric_limits<char8_t>;    // C++20 特性
    template<> class numeric_limits<char16_t>;   // C++11 特性
    template<> class numeric_limits<char32_t>;   // C++11 特性
    template<> class numeric_limits<short>;
    template<> class numeric_limits<unsigned short>;
    template<> class numeric_limits<int>;
    template<> class numeric_limits<unsigned int>;
    template<> class numeric_limits<long>;
    template<> class numeric_limits<unsigned long>;
    template<> class numeric_limits<long long>;
    template<> class numeric_limits<unsigned long long>;
    template<> class numeric_limits<float>;
    template<> class numeric_limits<double>;
    
    template<> class numeric_limits<long double>;

     

      
       

    另外,对于每个算术类型的每个 cv 限定版本存在特化,等同于非限定的特化,例如提供 std::numeric_limits<const int> 、 std::numeric_limits<volatile int> 和 std::numeric_limits<const volatile int> ,且它们等价于 std::numeric_limits<int> 。

    作为算术类型别名的标准库类型(例如 std::size_t 或 std::streamsize )也可以用 std::numeric_limits 类型特性检测。

    非算术标准类型,例如 std::complex<T> 或 std::nullptr_t ,无特化。

    实现可以对实现指定的类型提供 std::numeric_limits 的特化:例如 GCC 提供 std::numeric_limits<__int128> 。非标准库可以为库所提供的类型添加特化,例如 OpenEXR 为 16 位浮点类型提供 std::numeric_limits<half> 。

    模板参数

    T-要获取数值属性的类型

    成员常量

    is_specialized

    [静态]

    鉴别 std::numeric_limits 是否为该类型特化
    (公开静态成员常量)

    is_signed

    [静态]

    鉴别有符号类型
    (公开静态成员常量)

    is_integer

    [静态]

    鉴别整数类型
    (公开静态成员常量)

    is_exact

    [静态]

    鉴别准确表示的类型
    (公开静态成员常量)

    has_infinity

    [静态]

    鉴别能表示特殊值“正无穷大”的浮点类型
    (公开静态成员常量)

    has_quiet_NaN

    [静态]

    鉴别能表示特殊值“安静的非数”( NaN )的浮点类型
    (公开静态成员常量)

    has_signaling_NaN

    [静态]

    鉴别能表示特殊值“发信的非数”( NaN )的浮点类型
    (公开静态成员常量)

    has_denorm

    [静态]

    鉴别浮点类型所用的非正规风格
    (公开静态成员常量)

    has_denorm_loss

    [静态]

    鉴别浮点类型是否检测精度损失为非正规损失,而非不准确结果
    (公开静态成员常量)

    round_style

    [静态]

    鉴别类型所用的舍入模式
    (公开静态成员常量)

    is_iec559

    [静态]

    鉴别 IEC 559/IEEE 754 浮点类型
    (公开静态成员常量)

    is_bounded

    [静态]

    鉴别表示有限值集合的类型
    (公开静态成员常量)

    is_modulo

    [静态]

    鉴别以模算术处理溢出的类型
    (公开静态成员常量)

    digits

    [静态]

    能无更改地表示的 radix 位数
    (公开静态成员常量)

    digits10

    [静态]

    能无更改地表示的十进制位数
    (公开静态成员常量)

    max_digits10

    [静态](C++11)

    区别所有此类型值所需的十进制位数
    (公开静态成员常量)

    radix

    [静态]

    给定类型的表示所用的基或整数底
    (公开静态成员常量)

    min_exponent

    [静态]

    底的该数次幂是合法正规浮点值的最小负数加一
    (公开静态成员常量)

    min_exponent10

    [静态]

    10 的该数次幂是合法正规浮点值的最小负数
    (公开静态成员常量)

    max_exponent

    [静态]

    底的该数次幂是合法有限浮点值的最大整数加一
    (公开静态成员常量)

    max_exponent10

    [静态]

    10 的该数次幂是合法有限浮点值的最大整数
    (公开静态成员常量)

    traps

    [静态]

    鉴别可能导致算术运算出现陷阱的类型
    (公开静态成员常量)

    tinyness_before

    [静态]

    鉴别检测舍入前是否非正规的浮点类型
    (公开静态成员常量)

    成员函数

    min

    [静态]

    返回给定类型的最小有限值
    (公开静态成员函数)

    lowest

    [静态](C++11)

    返回给定类型的最低有限值
    (公开静态成员函数)

    max

    [静态]

    返回给定类型的最大有限值
    (公开静态成员函数)

    epsilon

    [静态]

    返回 1.0 与给定类型的下个可表示值的差
    (公开静态成员函数)

    round_error

    [静态]

    返回给定浮点类型的最大舍入误差
    (公开静态成员函数)

    infinity

    [静态]

    返回给定类型的正无穷大值
    (公开静态成员函数)

    quiet_NaN

    [静态]

    返回给定浮点类型的安静 NaN 值
    (公开静态成员函数)

    signaling_NaN

    [静态]

    返回给定浮点类型的发信的 NaN
    (公开静态成员函数)

    denorm_min

    [静态]

    返回给定浮点类型的最小正非正规值
    (公开静态成员函数)

    辅助类

    float_round_style

    指示浮点舍入模式
    (枚举)

    float_denorm_style

    指示浮点非规格化模式
    (枚举)

    与 C 库宏常量的关系

    特化成员
    min()lowest()
    (C++11)
    max()epsilon()digitsdigits10min_exponentmin_exponent10max_exponentmax_exponent10radix
    numeric_limits< bool >          2
    numeric_limits< char >CHAR_MINCHAR_MINCHAR_MAX       2
    numeric_limits< signed char >SCHAR_MINSCHAR_MINSCHAR_MAX       2
    numeric_limits< unsigned char >​0​​0​UCHAR_MAX       2
    numeric_limits< wchar_t >WCHAR_MINWCHAR_MINWCHAR_MAX       2
    numeric_limits< char8_t >​0​​0​UCHAR_MAX       2
    numeric_limits< char16_t >​0​​0​UINT_LEAST16_MAX       2
    numeric_limits< char32_t >​0​​0​UINT_LEAST32_MAX       2
    numeric_limits< short >SHRT_MINSHRT_MINSHRT_MAX       2
    numeric_limits< unsigned short >​0​​0​USHRT_MAX       2
    numeric_limits< int >INT_MININT_MININT_MAX       2
    numeric_limits< unsigned int >​0​​0​UINT_MAX       2
    numeric_limits< long >LONG_MINLONG_MINLONG_MAX       2
    numeric_limits< unsigned long >​0​​0​ULONG_MAX       2
    numeric_limits< long long >LLONG_MINLLONG_MINLLONG_MAX       2
    numeric_limits< unsigned long long >​0​​0​ULLONG_MAX       2
    numeric_limits< float >FLT_MIN-FLT_MAXFLT_MAXFLT_EPSILONFLT_MANT_DIGFLT_DIGFLT_MIN_EXPFLT_MIN_10_EXPFLT_MAX_EXPFLT_MAX_10_EXPFLT_RADIX
    numeric_limits< double >DBL_MIN-DBL_MAXDBL_MAXDBL_EPSILONDBL_MANT_DIGDBL_DIGDBL_MIN_EXPDBL_MIN_10_EXPDBL_MAX_EXPDBL_MAX_10_EXPFLT_RADIX
    numeric_limits< long double >LDBL_MIN-LDBL_MAXLDBL_MAXLDBL_EPSILONLDBL_MANT_DIGLDBL_DIGLDBL_MIN_EXPLDBL_MIN_10_EXPLDBL_MAX_EXPLDBL_MAX_10_EXPFLT_RADIX

    示例

    运行此代码

    #include <limits>
    #include <iostream>
     
    int main() 
    {
        std::cout << "type\tlowest()\tmin()\t\tmax()\n\n";
     
        std::cout << "uchar\t"
                  << +std::numeric_limits<unsigned char>::lowest() << '\t' << '\t'
                  << +std::numeric_limits<unsigned char>::min() << '\t' << '\t'
                  << +std::numeric_limits<unsigned char>::max() << '\n';
        std::cout << "int\t"
                  << std::numeric_limits<int>::lowest() << '\t'
                  << std::numeric_limits<int>::min() << '\t'
                  << std::numeric_limits<int>::max() << '\n';
        std::cout << "float\t"
                  << std::numeric_limits<float>::lowest() << '\t'
                  << std::numeric_limits<float>::min() << '\t'
                  << std::numeric_limits<float>::max() << '\n';
        std::cout << "double\t"
                  << std::numeric_limits<double>::lowest() << '\t'
                  << std::numeric_limits<double>::min() << '\t'
                  << std::numeric_limits<double>::max() << '\n';
    }

    可能的输出:

    type	lowest()	min()		max()
     
    uchar	0		0		255
    int	-2147483648	-2147483648	2147483647
    float	-3.40282e+38	1.17549e-38	3.40282e+38
    double	-1.79769e+308	2.22507e-308	1.79769e+308
    展开全文
  • 谁给我讲讲 sscanf 这个警告什么意思怎么改啊?我对这个理解不太透彻哇。 sscanf(buf, "%*[^<]<%[^>]>", iniDefaultPlate); sscanf(buf, "<%[^>]>", _platecolor[i].Color);...
  • This topic describes the memory limits for supported Windows and Windows Server releases. Limits on memory and address space vary by platform, operating system, and by whether theIMAGE_FILE_LARGE_AD....

    This topic describes the memory limits for supported Windows and Windows Server releases.

    Limits on memory and address space vary by platform, operating system, and by whether the IMAGE_FILE_LARGE_ADDRESS_AWARE value of the LOADED_IMAGE structure and 4-gigabyte tuning (4GT) are in use. IMAGE_FILE_LARGE_ADDRESS_AWARE is set or cleared by using the /LARGEADDRESSAWARE linker option.

    4-gigabyte tuning (4GT), also known as application memory tuning, or the /3GB switch, is a technology (only applicable to 32 bit systems) that alters the amount of virtual address space available to user mode applications. Enabling this technology reduces the overall size of the system virtual address space and therefore system resource maximums. For more information, see What is 4GT.

    Limits on physical memory for 32-bit platforms also depend on the Physical Address Extension (PAE), which allows 32-bit Windows systems to use more than 4 GB of physical memory.

    Memory and Address Space Limits

    The following table specifies the limits on memory and address space for supported releases of Windows. Unless otherwise noted, the limits in this table apply to all supported releases.

    Memory typeLimit on X86Limit in 64-bit Windows
    User-mode virtual address space for each 32-bit process2 GB
    Up to 3 GB with IMAGE_FILE_LARGE_ADDRESS_AWARE and 4GT
    2 GB with IMAGE_FILE_LARGE_ADDRESS_AWARE cleared (default)
    4 GB with IMAGE_FILE_LARGE_ADDRESS_AWARE set
    User-mode virtual address space for each 64-bit processNot applicableWith IMAGE_FILE_LARGE_ADDRESS_AWARE set (default):
    x64: 8 TB
    Intel Itanium-based systems: 7 TB
    Windows 8.1 and Windows Server 2012 R2: 128 TB

    2 GB with IMAGE_FILE_LARGE_ADDRESS_AWARE cleared
    Kernel-mode virtual address space2 GB
    From 1 GB to a maximum of 2 GB with 4GT
    8 TBWindows 8.1 and Windows Server 2012 R2: 128 TB
     
    Paged pool384 GB or system commit limit, whichever is smaller. Windows 8.1 and Windows Server 2012 R2: 15.5 TB or system commit limit, whichever is smaller.
    Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista: Limited by available kernel-mode virtual address space. Starting with Windows Vista with Service Pack 1 (SP1), the paged pool can also be limited by the PagedPoolLimit registry key value.
    Windows Home Server and Windows Server 2003: 530 MB
    Windows XP: 490 MB
     
    384 GB or system commit limit, whichever is smaller Windows 8.1 and Windows Server 2012 R2: 15.5 TB or system commit limit, whichever is smaller.
    Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista: 128 GB or system commit limit, whichever is smaller
    Windows Server 2003 and Windows XP: Up to 128 GB depending on configuration and RAM.
     
    Nonpaged pool75% of RAM or 2 GB, whichever is smaller. Windows 8.1 and Windows Server 2012 R2: RAM or 16 TB, whichever is smaller (address space is limited to 2 x RAM).
    Windows Vista: Limited only by kernel mode virtual address space and physical memory. Starting with Windows Vista with SP1, the nonpaged pool can also be limited by the NonPagedPoolLimit registry key value.
    Windows Home Server, Windows Server 2003 and Windows XP: 256 MB, or 128 MB with 4GT.
     
    RAM or 128 GB, whichever is smaller (address space is limited to 2 x RAM) Windows 8.1 and Windows Server 2012 R2: RAM or 16 TB, whichever is smaller (address space is limited to 2 x RAM).
    Windows Server 2008 R2, Windows 7 and Windows Server 2008: 75% of RAM up to a maximum of 128 GB
    Windows Vista: 40% of RAM up to a maximum of 128 GB.
    Windows Server 2003 and Windows XP: Up to 128 GB depending on configuration and RAM.
     
    System cache virtual address space (physical size limited only by physical memory)Limited by available kernel-mode virtual address space or the SystemCacheLimit registry key value.
    Windows 8.1 and Windows Server 2012 R2: 16 TB.
    Windows Vista: Limited only by kernel mode virtual address space. Starting with Windows Vista with SP1, system cache virtual address space can also be limited by the SystemCacheLimit registry key value.
    Windows Home Server, Windows Server 2003 and Windows XP: 860 MB with LargeSystemCache registry key set and without 4GT; up to 448 MB with 4GT.
     
    Always 1 TB regardless of physical RAM Windows 8.1 and Windows Server 2012 R2: 16 TB.
    Windows Server 2003 and Windows XP: Up to 1 TB depending on configuration and RAM.
     

     

    Physical Memory Limits: Windows 10

    The following table specifies the limits on physical memory for Windows 10.

    VersionLimit on X86Limit on X64
    Windows 10 Enterprise4 GB6 TB
    Windows 10 Education4 GB2 TB
    Windows 10 Pro for Workstations4 GB6 TB
    Windows 10 Pro4 GB2 TB
    Windows 10 Home4 GB128 GB

     

    Physical Memory Limits: Windows Server 2016

    The following table specifies the limits on physical memory for Windows Server 2016.

    VersionLimit on X64
    Windows Server 2016 Datacenter24 TB
    Windows Server 2016 Standard24 TB

     

    Physical Memory Limits: Windows 8

    The following table specifies the limits on physical memory for Windows 8.

    VersionLimit on X86Limit on X64
    Windows 8 Enterprise4 GB512 GB
    Windows 8 Professional4 GB512 GB
    Windows 84 GB128 GB

     

    Physical Memory Limits: Windows Server 2012

    The following table specifies the limits on physical memory for Windows Server 2012. Windows Server 2012 is available only in X64 editions.

    VersionLimit on X64
    Windows Server 2012 Datacenter4 TB
    Windows Server 2012 Standard4 TB
    Windows Server 2012 Essentials64 GB
    Windows Server 2012 Foundation32 GB
    Windows Storage Server 2012 Workgroup32 GB
    Windows Storage Server 2012 Standard4 TB
    Hyper-V Server 20124 TB

     

    Physical Memory Limits: Windows 7

    The following table specifies the limits on physical memory for Windows 7.

    VersionLimit on X86Limit on X64
    Windows 7 Ultimate4 GB192 GB
    Windows 7 Enterprise4 GB192 GB
    Windows 7 Professional4 GB192 GB
    Windows 7 Home Premium4 GB16 GB
    Windows 7 Home Basic4 GB8 GB
    Windows 7 Starter2 GBN/A

     

    Physical Memory Limits: Windows Server 2008 R2

    The following table specifies the limits on physical memory for Windows Server 2008 R2. Windows Server 2008 R2 is available only in 64-bit editions.

    VersionLimit on X64Limit on IA64
    Windows Server 2008 R2 Datacenter2 TB 
    Windows Server 2008 R2 Enterprise2 TB 
    Windows Server 2008 R2 for Itanium-Based Systems 2 TB
    Windows Server 2008 R2 Foundation8 GB 
    Windows Server 2008 R2 Standard32 GB 
    Windows HPC Server 2008 R2128 GB 
    Windows Web Server 2008 R232 GB 

     

    Physical Memory Limits: Windows Server 2008

    The following table specifies the limits on physical memory for Windows Server 2008. Limits greater than 4 GB for 32-bit Windows assume that PAE is enabled.

    VersionLimit on X86Limit on X64Limit on IA64
    Windows Server 2008 Datacenter64 GB1 TB 
    Windows Server 2008 Enterprise64 GB1 TB 
    Windows Server 2008 HPC Edition 128 GB 
    Windows Server 2008 Standard4 GB32 GB 
    Windows Server 2008 for Itanium-Based Systems  2 TB
    Windows Small Business Server 20084 GB32 GB 
    Windows Web Server 20084 GB32 GB 

     

    Physical Memory Limits: Windows Vista

    The following table specifies the limits on physical memory for Windows Vista.

    VersionLimit on X86Limit on X64
    Windows Vista Ultimate4 GB128 GB
    Windows Vista Enterprise4 GB128 GB
    Windows Vista Business4 GB128 GB
    Windows Vista Home Premium4 GB16 GB
    Windows Vista Home Basic4 GB8 GB
    Windows Vista Starter1 GB 

     

    Physical Memory Limits: Windows Home Server

    Windows Home Server is available only in a 32-bit edition. The physical memory limit is 4 GB.

    Physical Memory Limits: Windows Server 2003 R2

    The following table specifies the limits on physical memory for Windows Server 2003 R2. Limits over 4 GB for 32-bit Windows assume that PAE is enabled.

    VersionLimit on X86Limit on X64
    Windows Server 2003 R2 Datacenter Edition64 GB
    (16 GB with 4GT)
    1 TB
    Windows Server 2003 R2 Enterprise Edition64 GB
    (16 GB with 4GT)
    1 TB
    Windows Server 2003 R2 Standard Edition4 GB32 GB

     

    Physical Memory Limits: Windows Server 2003 with Service Pack 2 (SP2)

    The following table specifies the limits on physical memory for Windows Server 2003 with Service Pack 2 (SP2). Limits over 4 GB for 32-bit Windows assume that PAE is enabled.

    VersionLimit on X86Limit on X64Limit on IA64
    Windows Server 2003 with Service Pack 2 (SP2), Datacenter Edition64 GB
    (16 GB with 4GT)
    1 TB2 TB
    Windows Server 2003 with Service Pack 2 (SP2), Enterprise Edition64 GB
    (16 GB with 4GT)
    1 TB2 TB
    Windows Server 2003 with Service Pack 2 (SP2), Standard Edition4 GB32 GB 

     

    Physical Memory Limits: Windows Server 2003 with Service Pack 1 (SP1)

    The following table specifies the limits on physical memory for Windows Server 2003 with Service Pack 1 (SP1). Limits over 4 GB for 32-bit Windows assume that PAE is enabled.

    VersionLimit on X86Limit on X64Limit on IA64
    Windows Server 2003 with Service Pack 1 (SP1), Datacenter Edition64 GB
    (16 GB with 4GT)
    X64 1 TB1 TB
    Windows Server 2003 with Service Pack 1 (SP1), Enterprise Edition64 GB
    (16 GB with 4GT)
    X64 1 TB1 TB
    Windows Server 2003 with Service Pack 1 (SP1), Standard Edition4 GB32 GB 

     

    Physical Memory Limits: Windows Server 2003

    The following table specifies the limits on physical memory for Windows Server 2003. Limits over 4 GB for 32-bit Windows assume that PAE is enabled.

    VersionLimit on X86Limit on IA64
    Windows Server 2003, Datacenter Edition64 GB
    (16 GB with 4GT)
    512 GB
    Windows Server 2003, Enterprise Edition64 GB
    (16 GB with 4GT)
    512 GB
    Windows Server 2003, Standard Edition4 GB 
    Windows Server 2003, Web Edition2 GB 
    Windows Small Business Server 20034 GB 
    Windows Compute Cluster Server 2003 32 GB
    Windows Storage Server 2003, Enterprise Edition8 GB 
    Windows Storage Server 20034 GB 

     

    Physical Memory Limits: Windows XP

    The following table specifies the limits on physical memory for Windows XP.

    VersionLimit on X86Limit on X64Limit on IA64
    Windows XP4 GB128 GB128 GB (not supported)
    Windows XP Starter Edition512 MBN/AN/A

     

    Physical Memory Limits: Windows Embedded

    The following table specifies the limits on physical memory for Windows Embedded.

    VersionLimit on X86Limit on X64
    Windows XP Embedded4 GB 
    Windows Embedded Standard 20094 GB 
    Windows Embedded Standard 74 GB192 GB

     

    How graphics cards and other devices affect memory limits

    Devices have to map their memory below 4 GB for compatibility with non-PAE-aware Windows releases. Therefore, if the system has 4GB of RAM, some of it is either disabled or is remapped above 4GB by the BIOS. If the memory is remapped, X64 Windows can use this memory. X86 client versions of Windows don’t support physical memory above the 4GB mark, so they can’t access these remapped regions. Any X64 Windows or X86 Server release can.

    X86 client versions with PAE enabled do have a usable 37-bit (128 GB) physical address space. The limit that these versions impose is the highest permitted physical RAM address, not the size of the IO space. That means PAE-aware drivers can actually use physical space above 4 GB if they want. For example, drivers could map the "lost" memory regions located above 4 GB and expose this memory as a RAM disk.

    4-Gigabyte Tuning

    IMAGE_FILE_LARGE_ADDRESS_AWARE

    Physical Address Extension

     

     

    展开全文
  • 头文件<limits.h>

    2017-07-21 12:13:00
    limits.h>用来检测整型数据类型的表达式范围。 Linux version 2.6.32-573.el6.x86_64中<limits.h>源码: /* Copyright (C) 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2005 Free Software Foundation, ...

    头文件<limits.h>用来检测整型数据类型的表达式范围。

    Linux version 2.6.32-573.el6.x86_64中<limits.h>源码:

    /* Copyright (C) 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.

    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA. */

    /*
    * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>
    */

    #ifndef _LIBC_LIMITS_H_
    #define _LIBC_LIMITS_H_ 1

    #include <features.h>


    /* Maximum length of any multibyte character in any locale.
    We define this value here since the gcc header does not define
    the correct value. */
    #define MB_LEN_MAX 16


    /* If we are not using GNU CC we have to define all the symbols ourself.
    Otherwise use gcc's definitions (see below). */
    #if !defined __GNUC__ || __GNUC__ < 2


    /* We only protect from multiple inclusion here, because all the other
    #include's protect themselves, and in GCC 2 we may #include_next through
    multiple copies of this file before we get to GCC's. */
    # ifndef _LIMITS_H
    # define _LIMITS_H 1

    #include <bits/wordsize.h>

    /* We don't have #include_next.
    Define ANSI <limits.h> for standard 32-bit words. */

    /* These assume 8-bit `char's, 16-bit `short int's,
    and 32-bit `int's and `long int's. */

    /* Number of bits in a `char'. */
    # define CHAR_BIT 8

    /* Minimum and maximum values a `signed char' can hold. */
    # define SCHAR_MIN (-128)
    # define SCHAR_MAX 127

    /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
    # define UCHAR_MAX 255

    /* Minimum and maximum values a `char' can hold. */
    # ifdef __CHAR_UNSIGNED__
    # define CHAR_MIN 0
    # define CHAR_MAX UCHAR_MAX
    # else
    # define CHAR_MIN SCHAR_MIN
    # define CHAR_MAX SCHAR_MAX
    # endif

    /* Minimum and maximum values a `signed short int' can hold. */
    # define SHRT_MIN (-32768)
    # define SHRT_MAX 32767

     

    /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
    # define USHRT_MAX 65535

    /* Minimum and maximum values a `signed int' can hold. */
    # define INT_MIN (-INT_MAX - 1)
    # define INT_MAX 2147483647

    /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
    # define UINT_MAX 4294967295U

    /* Minimum and maximum values a `signed long int' can hold. */
    # if __WORDSIZE == 64
    # define LONG_MAX 9223372036854775807L
    # else
    # define LONG_MAX 2147483647L
    # endif
    # define LONG_MIN (-LONG_MAX - 1L)

    /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
    # if __WORDSIZE == 64
    # define ULONG_MAX 18446744073709551615UL
    # else
    # define ULONG_MAX 4294967295UL
    # endif

    # ifdef __USE_ISOC99

    /* Minimum and maximum values a `signed long long int' can hold. */
    # define LLONG_MAX 9223372036854775807LL
    # define LLONG_MIN (-LLONG_MAX - 1LL)

    /* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
    # define ULLONG_MAX 18446744073709551615ULL

    # endif /* ISO C99 */

    # endif /* limits.h */
    #endif /* GCC 2. */

    #endif /* !_LIBC_LIMITS_H_ */

    /* Get the compiler's limits.h, which defines almost all the ISO constants.

    We put this #include_next outside the double inclusion check because
    it should be possible to include this file more than once and still get
    the definitions from gcc's header. */
    #if defined __GNUC__ && !defined _GCC_LIMITS_H_
    /* `_GCC_LIMITS_H_' is what GCC's file defines. */
    # include_next <limits.h>
    #endif

    /* The <limits.h> files in some gcc versions don't define LLONG_MIN,
    LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for
    ages are available. */
    #if defined __USE_ISOC99 && defined __GNUC__
    # ifndef LLONG_MIN
    # define LLONG_MIN (-LLONG_MAX-1)
    # endif
    # ifndef LLONG_MAX
    # define LLONG_MAX __LONG_LONG_MAX__
    # endif
    # ifndef ULLONG_MAX
    # define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
    # endif
    #endif

    #ifdef __USE_POSIX
    /* POSIX adds things to <limits.h>. */
    # include <bits/posix1_lim.h>
    #endif

    #ifdef __USE_POSIX2
    # include <bits/posix2_lim.h>
    #endif

    #ifdef __USE_XOPEN
    # include <bits/xopen_lim.h>

    #endif

    其中常量含义:

    CHAR_BIT char的二进制位数(bit)
    CHAR_MAX char的有符号整数最大值
    CHAR_MIN char的有符号整数最小值
    MB_LEN_MAX 多字节字符的最大字节(byte)数
    INT_MAX int的有符号最大值
    INT_MIN int的有符号最小值
    LONG_MAX long的十进制最大值
    LONG_MIN long的十进制最小值
    SCHAR_MAX signedchar的十进制整数最大值
    SCHAR_MIN signedchar的十进制整数最小值
    SHRT_MIN short的十进制最小值
    SHRT_MAX short的十进制最大值
    UCHAR_MAX unsignedchar的十进制整数最大值
    UINT_MAX unsignedint的十进制最大值
    ULONG_MAX unsignedlongint的十进制最大值
    USHRT_MAX unsignedshortint的十进制最大值
     
    例:
    #if VAL<INT_MIN || VAL>INT_MAX
    #error values out of range
    #endif
    注:若VAL是double类型,会将INT_MIN隐式转换成double

    转载于:https://www.cnblogs.com/Mr-Wenyan/p/7217021.html

    展开全文
  • Changed limits: max_open_files: 5000 ( requested 50000 ) 2018-04-08T09:52:52 . 641467Z 0 [ Warning ] Changed limits: max_connections: 4190 ( requested 10000 ) 2018-04-08T09:...
  • Memory Limits for Windows and Windows Server Releases This topic describes the memory limits for supported Windows and Windows Server releases. Memory and Address Space Limits Physical Memory.....
  • B Curiosity Has No Limits

    2018-10-22 10:25:16
    Curiosity Has No Limits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output When Masha came to math classes today, she saw two inte.....
  • Increasing Speed Limits

    2014-08-05 18:36:57
    Increasing Speed Limits Time Limit: 2000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 133 Accepted Submission(s): 64  
  • Quotas and Limits Phase 1

    2020-12-31 06:43:27
    <p>The QS is designed so that it is safe to be accessed from multiple goroutines without using mutexes and also the API for consuming is asynchronous around a channel to allow e.g. instances to be ...
  • Cartographer 2.map_limits.h

    2018-07-04 18:57:44
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ...
  • ,containerID=container_1525923400969_0023_01_000002] is running beyond physical memory limits. Current usage: 1.0 GB of 1 GB physical memory used; 2.8 GB of 2.1 GB virtual memory used. ...
  • <div><p>if a domain or account has it limits reduced to below the amount of data it already has then the hmailadmin gui allows the change without validating it. Then any backup which is restored ...
  • Physical Database Limits

    2013-04-27 19:03:08
    ... GB (without K/M modifier) ... GB (without K/M modifier) ...Operating system dependent....Number of tablespaces cannot ...http://docs.oracle.com/cd/E11882_01/server.112/e25513/limits002.htm#REFRN0042
  • 原文地址In previous Pushing the Limits posts, I described the two most basic system resources, physical memory and virtual memory. This time I’m going to describe two fundamental kernel resources, ...
  • his topic describes memory limits for supported Windows releases:Memory and Address Space LimitsPhysical Memory Limits: Windows 7Physical Memory Limits: Windows Server 2008 R2Physical Memory Limits...
  • max ⁡ λ ∑ s ∈ S λ s L D s ( h ) = min ⁡ θ max ⁡ λ ∑ i = 0 n λ s i l ( h ( x i ) , y i ) J(\theta, \lambda) := \min\limits_{\theta}\max\limits_{\lambda}L(\theta, \lambda) = \min\limits_{\...
  • 1.memory leak:buf 调用malloc分配内存时,后续没有释放; 在函数return前free(buf) ...提示:sscanf without field width limits can crash with hurge input data; sscanf("%8s\n",&buf);
  • From:http://www.cplusplus.com/reference/std/limits/numeric_limits/ numeric_limits   浮点数据精度判断 float x=0.0; float y=0.0f;   if ( abs(x -y) &lt;= numeric_limits&lt;float&...
  • <div><p>The default 40GB system partition are idiotic without the settings even container snapper images. Would it be possible account for download/install needs and perform them in sets that are ...
  • vi /etc/security/limits.conf * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535 之后重启服务器。 [root@ aerchi.com  ~]#  mysqld_safe Starting mysqld daemon ...
  • s t : lim ⁡ z → ∞ g ( z ) = 0 st: \lim\limits_{z\rarr \infty} g(z) = 0 st:z→∞lim​g(z)=0 例如: g ( ∇ u 0 ( x , y ) ) = 1 1 + ∣ ∇ G σ ∗ u 0 ( x , y ) ∣ p g(\nabla u_0(x, y)) = \frac{1}{1 +...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 19,687
精华内容 7,874
关键字:

limitswithout