如果启用了模块,则tgmath.h不起作用 [英] tgmath.h doesn't work if modules are enabled

查看:158
本文介绍了如果启用了模块,则tgmath.h不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在处理arm64时使用 tgmath.h 来处理 CGFloat typedef float / double 混乱。

I looked into using tgmath.h to deal with the CGFloat typedef float/double mess when dealing with arm64.

这个答案对如何使用它有很好的描述,除了它对我来说根本不起作用。无论如何,我的代码仍在调用 math.h 函数。

This answer has a pretty good description of how to use it, except that it didn't work at all for me. No matter what, my code was still calling the math.h functions.

花了一些时间查看全部项目编译器设置,我发现禁用模块功能( @import vs #import - iOS 7 )使一切顺利。更具体地说,项目设置中的选项在 Apple LLVM 5.1 - 语言 - 模块中称为启用模块(C和Objective-C) 下拉。

After spending some time looking at all of the project compiler settings, I found that disabling the "Modules" feature (@import vs #import - iOS 7) makes it all work. More specifically, the option in the project settings is called Enable Modules(C and Objective-C) in the Apple LLVM 5.1 - Language - Modules dropdown.

要查看此问题的快速示例,请下载使用tgmath的项目,,例如MBProgressHUD ,看看启用模块项目设置时会发生什么。 tgmath.h 调用将被常规 math.h 调用替换。

To see a quick example of this issue, download a project that uses tgmath, such as MBProgressHUD, and see what happens when you enable the modules project setting. The tgmath.h calls get replaced with regular math.h calls.

我的问题是:


  1. 为什么模块会阻止tgmath被正确导入?

  1. Why do modules prevent tgmath from being imported properly?

有没有办法绕过它并同时使用tgmath和模块?我仍然希望能够使用它们。

Is there a way to get around it and use both tgmath and modules? I would like to still be able to use them.


推荐答案

我我不确定是什么导致了这个问题,但作为一种解决方法,你至少可以禁用你正在使用的文件的模块 tgmath.h

I'm not sure what's causing the issue, but as a workaround you could at least disable modules for only the file(s) where you're using tgmath.h:


  • 导航到Xcode中目标的Build Phases选项卡。

  • 在Compile Sources阶段,找到源文件。

  • 双击源文件并在Compiler Flags popover中键入 -fno-modules 以禁用该文件的Clang模块。

  • Navigate to the target's Build Phases tab in Xcode.
  • Under the Compile Sources phase, locate the source files.
  • Double-click the source file and type -fno-modules in the Compiler Flags popover to disable Clang modules for that file.

至少在这种方式下,您仍可以在项目的大部分时间内获得模块的好处。 (当然,假设您在大多数源文件中不需要 tgmath.h 。)

At least this way you would still get the benefits of modules in most of your project. (This is assuming, of course, you don't need tgmath.h in the majority of your source files.)

这篇关于如果启用了模块,则tgmath.h不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆