• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ COMPILE_TIME_ASSERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中COMPILE_TIME_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ COMPILE_TIME_ASSERT函数的具体用法?C++ COMPILE_TIME_ASSERT怎么用?C++ COMPILE_TIME_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了COMPILE_TIME_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: get_mpi

/*
 * Initializes a MPI.
 *
 * A temporary MPI is allocated and if a bigInt is supplied the MPI is
 * initialized with the value of the bigInt.
 */
static void get_mpi(mbedtls_mpi *mpi, const TEE_BigInt *bigInt)
{
	/*
	 * The way the GP spec is defining the bignums it's
	 * difficult/tricky to do it using 64-bit arithmetics given that
	 * we'd need 64-bit alignment of the data as well.
	 */
	COMPILE_TIME_ASSERT(sizeof(mbedtls_mpi_uint) == sizeof(uint32_t));

	/*
	 * The struct bigint_hdr is the overhead added to the bigint and
	 * is required to take exactly 2 uint32_t.
	 */
	COMPILE_TIME_ASSERT(sizeof(struct bigint_hdr) ==
			    sizeof(uint32_t) * BIGINT_HDR_SIZE_IN_U32);

	mbedtls_mpi_init_mempool(mpi);

	if (bigInt) {
		const struct bigint_hdr *hdr = (struct bigint_hdr *)bigInt;
		const mbedtls_mpi_uint *p = (const mbedtls_mpi_uint *)(hdr + 1);
		size_t n = hdr->nblimbs;

		/* Trim of eventual insignificant zeroes */
		while (n && !p[n - 1])
			n--;

		MPI_CHECK(mbedtls_mpi_grow(mpi, n));
		mpi->s = hdr->sign;
		memcpy(mpi->p, p, n * sizeof(mbedtls_mpi_uint));
	}
}
开发者ID:pascal-brand-st-dev,项目名称:optee_os,代码行数:38,代码来源:tee_api_arith_mpi.c


示例2: Sqrt

 typename xtl::TypeTraits<T>::LengthType Sqrt(const T& a)
 {
     typedef typename xtl::TypeTraits<T>::LengthType LengthType;
     COMPILE_TIME_ASSERT(xtl::TypeTraits<T>::IsArithmetic);
     COMPILE_TIME_ASSERT(xtl::TypeTraits<LengthType>::IsReal);
     return sqrt(xtl::RealCast<LengthType>(a));
 }
开发者ID:VideoKit,项目名称:VideoCollage,代码行数:7,代码来源:Vtl_Utility.hpp


示例3: COMPILE_TIME_ASSERT

void CSocketAddress::ApplyStunXorMap(const StunTransactionId& transid)
{
    const size_t iplen = (_address.addr.sa_family == AF_INET) ? STUN_IPV4_LENGTH : STUN_IPV6_LENGTH;
    uint8_t* pPort;
    uint8_t* pIP;

    if (_address.addr.sa_family == AF_INET)
    {
        COMPILE_TIME_ASSERT(sizeof(_address.addr4.sin_addr) == STUN_IPV4_LENGTH); // 4
        COMPILE_TIME_ASSERT(sizeof(_address.addr4.sin_port) == 2);

        pPort = (uint8_t*)&(_address.addr4.sin_port);
        pIP = (uint8_t*)&(_address.addr4.sin_addr);
    }
    else
    {
        COMPILE_TIME_ASSERT(sizeof(_address.addr6.sin6_addr) == STUN_IPV6_LENGTH); // 16
        COMPILE_TIME_ASSERT(sizeof(_address.addr6.sin6_port) == 2);
        pPort = (uint8_t*)&(_address.addr6.sin6_port);
        pIP = (uint8_t*)&(_address.addr6.sin6_addr);
    }
    
    pPort[0] = pPort[0] ^ transid.id[0];
    pPort[1] = pPort[1] ^ transid.id[1];
    
    for (size_t i = 0; i < iplen; i++)
    {
        pIP[i] = pIP[i] ^ transid.id[i];
    }
}
开发者ID:lsy1990,项目名称:STUN-for-android-demo,代码行数:30,代码来源:socketaddress.cpp


示例4: super

PackUnix::PackUnix(InputFile *f) :
    super(f), exetype(0), blocksize(0), overlay_offset(0), lsize(0)
{
    COMPILE_TIME_ASSERT(sizeof(Elf32_Ehdr) == 52);
    COMPILE_TIME_ASSERT(sizeof(Elf32_Phdr) == 32);
    COMPILE_TIME_ASSERT(sizeof(b_info) == 12);
    COMPILE_TIME_ASSERT(sizeof(l_info) == 12);
    COMPILE_TIME_ASSERT(sizeof(p_info) == 12);
}
开发者ID:tfauck,项目名称:upx,代码行数:9,代码来源:p_unix.cpp


示例5: stm_init

/*
 * Called once (from main) to initialize STM infrastructure.
 */
_CALLCONV void
stm_init(void)
{
#if CM == CM_MODULAR
    char *s;
#endif /* CM == CM_MODULAR */
#ifdef SIGNAL_HANDLER
    struct sigaction act;
#endif /* SIGNAL_HANDLER */

    PRINT_DEBUG("==> stm_init()\n");

    if (_tinystm.initialized)
        return;

    PRINT_DEBUG("\tsizeof(word)=%d\n", (int)sizeof(stm_word_t));

    PRINT_DEBUG("\tVERSION_MAX=0x%lx\n", (unsigned long)VERSION_MAX);

    COMPILE_TIME_ASSERT(sizeof(stm_word_t) == sizeof(void *));
    COMPILE_TIME_ASSERT(sizeof(stm_word_t) == sizeof(atomic_t));

#ifdef EPOCH_GC
    gc_init(stm_get_clock);
#endif /* EPOCH_GC */

#if CM == CM_MODULAR
    s = getenv(VR_THRESHOLD);
    if (s != NULL)
        _tinystm.vr_threshold = (int)strtol(s, NULL, 10);
    else
        _tinystm.vr_threshold = VR_THRESHOLD_DEFAULT;
    PRINT_DEBUG("\tVR_THRESHOLD=%d\n", _tinystm.vr_threshold);
#endif /* CM == CM_MODULAR */

    /* Set locks and clock but should be already to 0 */
    memset((void *)_tinystm.locks, 0, LOCK_ARRAY_SIZE * sizeof(stm_word_t));
    CLOCK = 0;

    stm_quiesce_init();

    tls_init();

#ifdef SIGNAL_HANDLER
    if (getenv(NO_SIGNAL_HANDLER) == NULL) {
        /* Catch signals for non-faulting load */
        act.sa_handler = signal_catcher;
        act.sa_flags = 0;
        sigemptyset(&act.sa_mask);
        if (sigaction(SIGBUS, &act, NULL) < 0 || sigaction(SIGSEGV, &act, NULL) < 0) {
            perror("sigaction");
            exit(1);
        }
    }
#endif /* SIGNAL_HANDLER */
    _tinystm.initialized = 1;
}
开发者ID:kunulee,项目名称:failsafe_heapo_source,代码行数:60,代码来源:stm.c


示例6: COMPILE_TIME_ASSERT

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CObjectBuffStation::CObjectBuffStation()
{
	// Verify networking data.
	COMPILE_TIME_ASSERT( BUFF_STATION_MAX_PLAYERS < ( 1 << BUFF_STATION_MAX_PLAYER_BITS ) );
	COMPILE_TIME_ASSERT( BUFF_STATION_MAX_PLAYERS >= ( 1 << ( BUFF_STATION_MAX_PLAYER_BITS - 1 ) ) );

	COMPILE_TIME_ASSERT( BUFF_STATION_MAX_OBJECTS < ( 1 << BUFF_STATION_MAX_OBJECT_BITS ) );
	COMPILE_TIME_ASSERT( BUFF_STATION_MAX_OBJECTS >= ( 1 << ( BUFF_STATION_MAX_OBJECT_BITS - 1 ) ) );

	// Uses the client-side animation system.
	UseClientSideAnimation();
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:15,代码来源:tf_obj_buff_station.cpp


示例7: sanity_checks

static void sanity_checks()
{
  COMPILE_TIME_ASSERT(sizeof(convert_64_t) == 8);
  COMPILE_TIME_ASSERT(sizeof(convert_32_t) == 4);
  COMPILE_TIME_ASSERT(sizeof(stm_word_t) == 4 || sizeof(stm_word_t) == 8);
  COMPILE_TIME_ASSERT(sizeof(char) == 1);
  COMPILE_TIME_ASSERT(sizeof(short) == 2);
  COMPILE_TIME_ASSERT(sizeof(int) == 4);
  COMPILE_TIME_ASSERT(sizeof(long) == 4 || sizeof(long) == 8);
  COMPILE_TIME_ASSERT(sizeof(float) == 4);
  COMPILE_TIME_ASSERT(sizeof(double) == 8);
}
开发者ID:dution89630,项目名称:my-school-work,代码行数:12,代码来源:wrappers.c


示例8: COMPILE_TIME_ASSERT

XmlNodeRef CScoreIncEvent::GetXML(IGameStatistics* pGS)
{
	XmlNodeRef node = pGS->CreateStatXMLNode();

	node->setAttr("score", m_score);

	COMPILE_TIME_ASSERT(EGRST_Num==ARRAY_COUNT(k_ScoreIncTypeStrs));

	EGameRulesScoreType type=m_type;

	const char *pStr = "Unknown";
	if (m_type>=0 && m_type<ARRAY_COUNT(k_ScoreIncTypeStrs))
	{
		pStr = k_ScoreIncTypeStrs[m_type];
	}

	// skip code prefixes from enums to make them more human readable
	if (strncmp(pStr,"EGRST_",6)==0)
	{
		pStr+=6;
	}

	node->setAttr("type", pStr);

	return node;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:26,代码来源:StatHelpers.cpp


示例9: Square

 typename xtl::TypeTraits<T>::AccumType Square(const T& a)
 {
     COMPILE_TIME_ASSERT(xtl::TypeTraits<T>::IsArithmetic);
     typedef typename xtl::TypeTraits<T>::AccumType AccumType;
     AccumType b = xtl::RealCast<AccumType>(a);
     return b * b;
 }
开发者ID:VideoKit,项目名称:VideoCollage,代码行数:7,代码来源:Vtl_Utility.hpp


示例10: super

PackVmlinuzI386::PackVmlinuzI386(InputFile *f) :
    super(f), physical_start(0x100000), page_offset(0), config_physical_align(0)
    , filter_len(0)
{
    bele = &N_BELE_RTP::le_policy;
    COMPILE_TIME_ASSERT(sizeof(boot_sect_t) == 0x250);
}
开发者ID:IngwiePhoenix,项目名称:drag0n-src,代码行数:7,代码来源:p_vmlinz.cpp


示例11: ASSERT

HRESULT CSocketAddress::GetLocalHost(uint16_t family, CSocketAddress* pAddr)
{
    
    if (  ((family != AF_INET) && (family != AF_INET6)) || 
          (pAddr == NULL))
    {
        ASSERT(false);
        return E_FAIL;
    }
    
    if (family == AF_INET)
    {
        uint32_t ip = 0x7f000001; // 127.0.0.1 in host byte order
        *pAddr = CSocketAddress(ip, 0);
    }
    else
    {
        sockaddr_in6 addr6 = {};
        COMPILE_TIME_ASSERT(sizeof(addr6.sin6_addr) == 16);
        
        // ::1
        uint8_t ip6[16] = {};
        ip6[15] = 1;

        addr6.sin6_family = AF_INET6;
        memcpy(&addr6.sin6_addr, ip6, 16);
        *pAddr = CSocketAddress(addr6);
    }
    
    return S_OK;
}
开发者ID:lsy1990,项目名称:STUN-for-android-demo,代码行数:31,代码来源:socketaddress.cpp


示例12: Identify

BOOL Identify(HANDLE hPhysical)
{
	ATA_PASSTHROUGH_CMD Command = {0};
	IDENTIFY_DEVICE_DATA* idd;
	int i, r;

	Command.AtaCmd = ATA_IDENTIFY_DEVICE;

	// You'll get an error here if your compiler does not properly pack the IDENTIFY struct
	COMPILE_TIME_ASSERT(sizeof(IDENTIFY_DEVICE_DATA) == 512);

	idd = (IDENTIFY_DEVICE_DATA*)_mm_malloc(sizeof(IDENTIFY_DEVICE_DATA), 0x10);
	if (idd == NULL)
		return FALSE;

	for (i=0; i<ARRAYSIZE(pt); i++) {
		r = pt[i].fn(hPhysical, &Command, idd, sizeof(IDENTIFY_DEVICE_DATA), SPT_TIMEOUT_VALUE);
		if (r == SPT_SUCCESS) {
			uprintf("Success using %s\n", pt[i].type);
			if (idd->CommandSetSupport.SmartCommands) {
				DumpBufferHex(idd, sizeof(IDENTIFY_DEVICE_DATA));
				uprintf("SMART support detected!\n");
			} else {
				uprintf("No SMART support\n");
			}
			break;
		}
		uprintf("No joy with: %s (%s)\n", pt[i].type, SptStrerr(r));
	}
	if (i >= ARRAYSIZE(pt))
		uprintf("NO ATA FOR YOU!\n");

	_mm_free(idd);
	return TRUE;
}
开发者ID:10se1ucgo,项目名称:rufus,代码行数:35,代码来源:smart.c


示例13: COMPILE_TIME_ASSERT

static void *raw_malloc(size_t hdr_size, size_t ftr_size, size_t pl_size)
{
	void *ptr = NULL;
	size_t s = hdr_size + ftr_size + pl_size;

	/*
	 * Make sure that malloc has correct alignment of returned buffers.
	 * The assumption is that uintptr_t will be as wide as the largest
	 * required alignment of any type.
	 */
	COMPILE_TIME_ASSERT(SizeQuant >= sizeof(uintptr_t));

	raw_malloc_validate_pools();

	/* Check wrapping */
	if (s < pl_size)
		goto out;

	/* BGET doesn't like 0 sized allocations */
	if (!s)
		s++;

	ptr = bget(s);
out:
	raw_malloc_return_hook(ptr, pl_size);

	return ptr;
}
开发者ID:jforissier,项目名称:optee_os,代码行数:28,代码来源:bget_malloc.c


示例14: grub_netbuff_alloc

struct grub_net_buff *
grub_netbuff_alloc (grub_size_t len)
{
  struct grub_net_buff *nb;
  void *data;

  COMPILE_TIME_ASSERT (NETBUFF_ALIGN % sizeof (grub_properly_aligned_t) == 0);

  if (len < NETBUFFMINLEN)
    len = NETBUFFMINLEN;

  len = ALIGN_UP (len, NETBUFF_ALIGN);
#ifdef GRUB_MACHINE_EMU
  data = grub_malloc (len + sizeof (*nb));
#else
  data = grub_memalign (NETBUFF_ALIGN, len + sizeof (*nb));
#endif
  if (!data)
    return NULL;
  nb = (struct grub_net_buff *) ((grub_properly_aligned_t *) data
				 + len / sizeof (grub_properly_aligned_t));
  nb->head = nb->data = nb->tail = data;
  nb->end = (grub_uint8_t *) nb;
  return nb;
}
开发者ID:Der-Jan,项目名称:grub-zfs,代码行数:25,代码来源:netbuff.c


示例15: _cairo_xcb_connection_shm_attach

uint32_t
_cairo_xcb_connection_shm_attach (cairo_xcb_connection_t *connection,
                                  uint32_t id,
                                  cairo_bool_t readonly)
{
    struct {
        uint8_t req;
        uint8_t shm_req;
        uint16_t length;
        uint32_t segment;
        uint32_t id;
        uint8_t readonly;
        uint8_t pad1;
        uint16_t pad2;
    } req;
    struct iovec vec[1];

    COMPILE_TIME_ASSERT (sizeof (req) == 16);

    req.req = connection->shm->major_opcode;
    req.shm_req = 1;
    req.length = sizeof (req) >> 2;
    req.segment = _cairo_xcb_connection_get_xid (connection);
    req.id = id;
    req.readonly = readonly;

    vec[0].iov_base = &req;
    vec[0].iov_len = sizeof (req);

    _cairo_xcb_connection_write (connection, vec, 1);
    return req.segment;
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:32,代码来源:cairo-xcb-connection-shm.c


示例16: Assert

//-----------------------------------------------------------------------------
// Gets at the nth item in the list
//-----------------------------------------------------------------------------
TrailPoint_t *CSpriteTrail::GetTrailPoint( int n )
{
	Assert( n < MAX_SPRITE_TRAIL_POINTS );
	COMPILE_TIME_ASSERT( (MAX_SPRITE_TRAIL_POINTS & (MAX_SPRITE_TRAIL_POINTS-1)) == 0 );
	int nIndex = (n + m_nFirstStep) & MAX_SPRITE_TRAIL_MASK; 
	return &m_vecSteps[nIndex];
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:10,代码来源:spritetrail.cpp


示例17: _cairo_xcb_connection_shm_detach

void
_cairo_xcb_connection_shm_detach (cairo_xcb_connection_t *connection,
                                  uint32_t segment)
{
    struct {
        uint8_t req;
        uint8_t shm_req;
        uint16_t length;
        uint32_t segment;
    } req;
    struct iovec vec[1];

    COMPILE_TIME_ASSERT (sizeof (req) == 8);

    req.req = connection->shm->major_opcode;
    req.shm_req = 2;
    req.length = sizeof (req) >> 2;
    req.segment = segment;

    vec[0].iov_base = &req;
    vec[0].iov_len = sizeof (req);

    _cairo_xcb_connection_write (connection, vec, 1);
    _cairo_xcb_connection_put_xid (connection, segment);
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:25,代码来源:cairo-xcb-connection-shm.c


示例18: GetConfiguration

	virtual void GetConfiguration( SFlowNodeConfig& config )
	{
		COMPILE_TIME_ASSERT( PORT_NONE + 1 == 0 );  // or else the automatic boundary checks when incrememting the port number would not work

		static const SInputPortConfig in_config[] = {
			InputPortConfig_AnyType("In", _HELP("Input")),
			InputPortConfig<bool> ( "Closed", false, _HELP("If true blocks all signals.")),
			InputPortConfig_Void  ( "Open", _HELP("Sets [Closed] to false.")),
			InputPortConfig_Void  ( "Close", _HELP("Sets [Closed] to true.")),
			InputPortConfig_Void	("Reset", _HELP("Forces next output to be Port1 again")),
			InputPortConfig<bool> ( "Reverse", false, _HELP("If true, the order of output activation is reversed.")),
			{0}
		};
		static const SOutputPortConfig out_config[] = {
			OutputPortConfig_AnyType("Out1", _HELP("Output1")),
			OutputPortConfig_AnyType("Out2", _HELP("Output2")),
			OutputPortConfig_AnyType("Out3", _HELP("Output3")),
			OutputPortConfig_AnyType("Out4", _HELP("Output4")),
			OutputPortConfig_AnyType("Out5", _HELP("Output5")),
			OutputPortConfig_AnyType("Out6", _HELP("Output6")),
			OutputPortConfig_AnyType("Out7", _HELP("Output7")),
			OutputPortConfig_AnyType("Out8", _HELP("Output8")),
			OutputPortConfig_AnyType("Out9", _HELP("Output9")),
			OutputPortConfig_AnyType("Out10", _HELP("Output10")),
			{0}
		};
		config.sDescription = _HELP("On each [In] trigger, triggers one of the connected outputs in sequential order.");
		config.pInputPorts = in_config;
		config.pOutputPorts = out_config;
		config.nFlags |= EFLN_AISEQUENCE_SUPPORTED;
		config.SetCategory(EFLN_APPROVED);
	}
开发者ID:aronarts,项目名称:FireNET,代码行数:32,代码来源:FlowLogicNodes.cpp


示例19: Assert

const cascade_t &GetCascadeInfo( int index )
{
	Assert( index >= 0 && index < iNumCascades );
	COMPILE_TIME_ASSERT( iNumCascades == SHADOW_NUM_CASCADES );

	return g_CascadeInfo[ index ];
}
开发者ID:DonnaLisa,项目名称:swarm-deferred,代码行数:7,代码来源:cascade_t.cpp


示例20: tee_svc_handler

void tee_svc_handler(struct thread_svc_regs *regs)
{
	size_t scn;
	size_t max_args;
	syscall_t scf;

	COMPILE_TIME_ASSERT(ARRAY_SIZE(tee_svc_syscall_table) ==
				(TEE_SCN_MAX + 1));

	/* Restore IRQ which are disabled on exception entry */
	thread_restore_irq();

	thread_disable_concurrency();

	get_scn_max_args(regs, &scn, &max_args);

#if (TRACE_LEVEL == TRACE_FLOW) && defined(CFG_TEE_CORE_TA_TRACE)
	tee_svc_trace_syscall(scn);
#endif

	if (max_args > TEE_SVC_MAX_ARGS) {
		DMSG("Too many arguments for SCN %zu (%zu)", scn, max_args);
		set_svc_retval(regs, TEE_ERROR_GENERIC);
		return;
	}

	if (scn > TEE_SCN_MAX)
		scf = syscall_nocall;
	else
		scf = tee_svc_syscall_table[scn];

	set_svc_retval(regs, tee_svc_do_call(regs, scf));

	thread_enable_concurrency();
}
开发者ID:sybtjp,项目名称:optee_os,代码行数:35,代码来源:arch_svc.c



注:本文中的COMPILE_TIME_ASSERT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ COMPONENT_NAME_EX函数代码示例发布时间:2022-05-30
下一篇:
C++ COMPILE_ASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap