草庐IT

STDC_CONSTANT_MACROS

全部标签

c++ - constant 和 reinterpret cast 是否在编译时发生?

我读到过static_cast发生在编译时,dynamic_cast发生在运行时,因此比static_cast慢。dynamic_cast可以返回空指针(当与指针一起使用时)或以其他方式抛出错误的转换异常。我的问题是reinterpret_cast和const_cast是发生在编译时还是运行时?我认为解释转换发生在运行时,因为它的行为类似于dynamic_cast指示转换是否成功。我对么?const_cast是编译时间吗? 最佳答案 动态转换是唯一需要在运行时“计算”的。所有其他类型转换均在编译时计算。static_cast的机器代

c++ - 是否有针对 "conditional expression is constant"的 gcc 警告?

我继承了一个相当大的代码库,其中有人以某种方式编写了几个这样的条件:enum{FOO_TYPE_A,FOO_TYPE_B,FOO_TYPE_C,FOO_TYPE_D};voidbar(intfooType){if(fooType==FOO_TYPE_A||FOO_TYPE_B)//条件检查应该明确在哪里:if(fooType==FOO_TYPE_A||fooType==FOO_TYPE_B)在gcc中有没有警告我可以打开找到它们,类似于MSDN的C4127?具体来说,我使用的是AndroidNDKr9d。如果不是,为什么不呢?对于无意赋值,unsigned>0以及上述愚蠢行为,这似乎是

c++ - Qmake 不使用 stdc++11 编译标志

当我尝试编译我的项目时,我遇到了这个错误:g++-c-pipe-std=c++11-O2-g-pipe-Wall-Werror=format-security-Wp,-D_FORTIFY_SOURCE=2-fstack-protector-strong--param=ssp-buffer-size=4-grecord-gcc-switches-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1-m64-mtune=generic-std=gnu++98-Wno-deprecated-O2-Wall-W-D_REENTRANT-DQT_NO_DEB

c++ - 为什么不允许优化器折叠 "constant context"?

__builtin_is_constant_evaluated是用于在clang和gcc的标准库中实现std::is_constant_evaluated的内置函数。在常量上下文中无效的代码通常也更难被优化器常量折叠。例如:intf(inti){if(__builtin_is_constant_evaluated())return1;else{int*ptr=newint(1);inti=*ptr;deleteptr;returni;}}由gcc-O3发出:f(int):subrsp,8movedi,4calloperatornew(unsignedlong)movesi,4movrd

ios - swift : Multiple targets handling: macros not working

来自引用HowtohandlemultipletargetsinXCodeusingswiftlanguage?和https://www.appcoda.com/using-xcode-targets/我创建了三个目标,每个目标都有不同的包ID和应用程序图标。我还在“其他swift标志”->自定义swift标志部分添加了不同的标志喜欢对于我添加的第一个目标"-DGOLD",对于第二个目标,我添加了"-DSILVER"并为我添加的第三个目标"-DPLATINUM"。在AppDelegate中我写了一段代码#ifGOLDprint("Gold")#elseifSILVERprint("Si

ios - TableView :dequeueReusableCellWithIdentifier issues with "global" constant

请留住我的头发,或指出我的(明显的)错误。我正在尝试在子类化的UITableViewController中使用UITableViewCellStyleSubtitle的UITableViewStyle。我在实现中定义了一个静态常量:staticNSString*constkAHCellIdentifier;在viewDidLoad中,我注册了一个tableView类:[self.tableViewregisterClass:[UITableViewCellclass]forCellReuseIdentifier:kAHCellIdentifier];然后在tableView:cellF

ios - SpriteKit : Stuttering during movement with constant velocity

我正在开发一款带有sprite套件的简单飞行游戏。一旦spaceship达到最大高度和速度,它就会以恒定速度继续飞行。我注意到spaceship在不断的飞行过程中会随机出现断断续续的情况。我已经在这里阅读了所有关于这个问题的帖子,但没有什么能真正帮助100%解决它。为了测试,我写了一个非常简单的游戏,它只包含一艘spaceship和一个简单的云(代码如下)。但是即使在这个非常简单的游戏中,spaceship仍然会卡顿。LOG表明,即使飞船以恒定速度飞行,飞船运动也不是随机恒定的。这就是口吃的原因。希望有人能帮我解决这个问题。感谢您的任何想法。Sprite套件、Objectivec、Xc

php - Laravel View Composer "Use of undefined constant"

整个晚上都在看,这一切看起来都很简单,但就是行不通!刚开始并尝试将变量放入View中。无论我做什么,我似乎都无法阅读它。路由.php:Route::get('/',function(){returnView::make('dashboard');});View::composer('dashboard',function($view){$view->with('links',"something");});仪表板.blade.php:@extends('base_view')@section('content')Allthestuff!{{links}}@stopbase_view.b

php - 注意 : Use of undefined constant self - assumed 'self' , 当把 property_exists 作为第一个参数时

我正在尝试使用self而不是在propery_exists函数中键入类名,如下所示:privatestaticfunctioninstantiate($record){$user=newself;foreach($recordas$name=>$value){if(isset($user->$name)||property_exists(self,$name)){$user->$name=$value;}}return$user;}但是当我运行这个脚本时出现错误:Notice:Useofundefinedconstantself-assumed'self'in/var/www/phot

php - 那是什么意思 : Compare two strings $a and $b in length-constant time?

在学习密码哈希和数据库保存时,我发现了这篇文章:https://crackstation.net/hashing-security.htm#phpsourcecode一切都清楚了,除了这个函数,我无法准确理解为什么不使用正常的相等性?什么意思:在长度恒定的时间内比较两个字符串$a和$b。//Comparestwostrings$aand$binlength-constanttime.functionslow_equals($a,$b){$diff=strlen($a)^strlen($b);for($i=0;$i 最佳答案 通常比较