草庐IT

swift 3 : atomic_compare_exchange_strong

coder 2023-07-15 原文

在 Xcode 8/Swift 3 中收到以下警告:

warning: 'OSAtomicCompareAndSwap32Barrier' was deprecated in OS X 10.12:
         Use atomic_compare_exchange_strong() from <stdatomic.h> instead

尝试在 Swift 代码中使用函数 atomic_compare_exchange_strong 导致编译器错误:

error: use of unresolved identifier 'atomic_compare_exchange_strong'

导入 DarwinCoreFoundation 模块不能解决问题。

我应该导入什么模块才能获得 atomic_compare_exchange_strong 的符号?

谢谢!

最佳答案

我知道这是一个针对 Swift 3 的问题,但如果有人偶然发现这个问题,现在有一个 Swift Atomics package ( introduced in Oct 2020 ) 可用于此功能。

关于 swift 3 : atomic_compare_exchange_strong,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39356873/

有关swift 3 : atomic_compare_exchange_strong的更多相关文章

  1. Ruby - 使用 Comparable mixin 比较两个不同属性的对象 - 2

    有没有简单的方法(即使用宇宙飞船运算符)在Ruby中定义基于两个不同属性的比较?IE。如果我有一个包含两个属性attr1和attr2的类,是否有Rubyesque方法在attr1上比较此类的两个实例,如果它们相等,则在attr2上比较它们? 最佳答案 这是一种易于扩展(扩展到更多属性)的方式:def(other)[self.attr1,self.attr2][other.attr1,other.attr2]end 关于Ruby-使用Comparablemixin比较两个不同属性的对象,我

  2. ruby-on-rails - Rails Strong Parameters - 允许数组中的深层嵌套哈希 - 2

    如何允许/白名单具有非常不规则(无法声明)结构的深层嵌套哈希。例子:{"widgets"=>[{"id"=>75432,"conversion_goal_id"=>1331,"options"=>{"form_settings"=>{"formbuilder-bg-color"=>"rgba(255,255,255,0)","font-size"=>"14px","form-field-depth"=>"42px"},"linkedWidget"=>""},"type"=>"formbuilder-widget"},{"id"=>75433,"conversion_goal_id"=>

  3. ruby - 在 Atom 中运行 Ruby 程序 - 2

    我安装了Atom和脚本包,写了一个Ruby测试程序,保存为hello.rb,按下ctrl+shift+b执行,得到错误信息'ruby'不是内部或外部命令,也不是可运行的程序或批处理文件。我以为脚本包包含Ruby和其他多种语法。在运行程序之前我还需要做些什么吗? 最佳答案 我没有从Atom运行我的代码,但我认为您的问题的一个可能原因是您的机器上没有安装Ruby本身。Mac出厂时安装了Ruby,但Windows机器通常没有。查看http://rubyinstaller.org/.它是一个用于在Windows环境中安装Ruby的简单工具。

  4. ruby - 无法通过 SMTP 使 ActionMailer 与 MS Exchange 一起工作 - 2

    这是我的简单测试程序(使用ActionMailer3.0.8,Ruby1.9.2p180MacOSX):require'rubygems'require'action_mailer'ActionMailer::Base.delivery_method=:smtpActionMailer::Base.smtp_settings={:address=>"my_exchange_server",:port=>25,:domain=>'my_domain.org',:authentication=>:login,:user_name=>'my_user',:password=>'my_pass

  5. ruby-on-rails - 如何使用 strong_parameters 允许除 user_id 之外的所有属性? - 2

    我想使用类似的东西:defanswer_paramsparams.require(:answer).permit!.without(:user_id)end 最佳答案 这行得通吗?params.require(:answer).permit!.except(:user_id) 关于ruby-on-rails-如何使用strong_parameters允许除user_id之外的所有属性?,我们在StackOverflow上找到一个类似的问题: https://s

  6. ruby-on-rails - rails 4 : Forcing specific values with "strong parameters" - 2

    我正在努力使用用于创建“项目”的表单。最后,我只想允许当前的user_id,但我还没有构建用户模型或身份验证,因此作为占位符,我只是硬编码1。app/views/projects/new.html.erb:{:action=>'create'})do|f|%>1})%>app/controllers/projects_controller.rbdefcreate#saveobjectifProject.create(project_params)redirect_to(:action=>'show')elserender('new')endendprivatedefproject_pa

  7. ruby - 使用 strong_parameters 序列化数组 - 2

    我正在尝试使用strong_parametersgem保存一个数组。但是我对表单发送数组的方式有疑问。参数看起来像这样:>params[:circuit]=>{"title"=>"Sometitle",...,"viewable_tasks"=>{"0"=>"woop","1"=>"dee",...}}我的circuit_params函数如下所示:defcircuit_paramsparams.require(:circuit).permit(:title,:id,viewable_tasks:{},...)end我似乎无法获得允许我的参数工作的语法。我在控制台中得到的是:>circu

  8. ruby - 安装 Atomic 时出错 - 2

    我正在尝试使用bundleinstall将gems安装到我的新Ruby项目中。我在我的OSX10.8.4机器上使用rbenv设置了Ruby的版本。我收到以下错误:Anerroroccurredwhileinstallingatomic(1.1.13),andBundlercannotcontinue.Makesurethat`geminstallatomic-v'1.1.13'`succeedsbeforebundling.Kikime:jazzcatalogcurt$geminstallatomicBuildingnativeextensions.Thiscouldtakeawhil

  9. ruby-on-rails - Rails 安装错误 :The 'atomic' native gem requires installed build tools - 2

    这个问题在这里已经有了答案:The'json'nativegemrequiresinstalledbuildtools(8个答案)关闭7年前。我正在我的Windows上安装Rails3。我安装了最新的ruby​​2.0.0,并更新了gems。但是当我使用geminstallrails安装rails时,出现了成功的消息,但最后我找到了ERROR:Errorinstallingrails:The'atomic'nativegemrequiresinstalledbuildtoolsPleaseupdateyourPATHtoincludebuildtoolsordownloadtheDev

  10. ruby-on-rails - 为什么 Strong Params 包含允许的 : false - 2

    我在Controller的update操作顶部放入了一个binding.pry。在该断点处,我输入params[:foo_bar]来检查params散列。这是我得到的:"✓","_method"=>"patch","authenticity_token"=>"123==","foobar"=>{"start_date"=>"08/27/2016","end_date"=>"08/29/2016","id"=>"89"},"bazz_id"=>"3","abc_id"=>"330","bazzbazz_attributes"=>{"0"=>{"_destroy"=>"1","city_i

随机推荐