llvm报告用不兼容类型在不同翻译单元中声明的错误 [英] llvm reports error declared with incompatible types in different translation units

查看:369
本文介绍了llvm报告用不兼容类型在不同翻译单元中声明的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在OS X 10.9.2下调试XCode 5.1(5B130a)中的C ++ OS X应用程序。
该应用程序由各种库项目组成,可以编译成库并在主应用程序项目中使用。



我在代码中设置断点,在lldb中运行:

  expr 2 

这是我得到的:

 (lldb)expr 2 
错误:在不同的翻译单元中以不兼容类型声明的字段__f_('__base *'(aka'std :: __ 1 :: __ function :: __ base< void(std :: __ 1 :: shared_ptr< const XXX> ;, const YYY& > *')与'__base *'(aka'std :: __ 1 :: __ function :: __base *'))
错误:以不兼容类型在不同翻译单元中声明的字段__f_ '__base *'(aka'std :: __ 1 :: __ function :: __ base< void(std :: __ 1 :: shared_ptr< const XXX> ;, const YYY&)> *')vs.'__base *' 'std :: __ 1 :: __ function :: __ base< void> *'))
错误:预期表达式
注意:这里声明类型为'__base *'(aka'std :: __ 1 :: __ function :: __ base< void> *')
注意:这里声明类型为'__base *'(aka'std :: __ 1 :: __ function :: __ base< void> *')
错误:3错误解析表达式

请注意,如果我在代码中的其他位置设置断点,同样的命令可能会工作。这导致我认为我打破的具体库有所不同。



我理解有一个定义 std :: function< void(std :: shared_ptr< const XXX>,const YYY&)> ,并且一些其他翻译单元看到它具有不同的定义(我相信 __ f _ 是std :: function模板类的内部字段),但是对我来说不清楚:




  • 为什么不是链接器抱怨呢? (事实上​​,应用程序运行完美)

  • 什么代码生成开关不匹配可能会导致这种情况?我已经查看了 GCC_OPTIMIZATION_LEVEL (所有 -O0 ), COPY_PHASE_STRIP ,...



谢谢!

解决方案>

这很可能是调试信息的问题,而不是生成的代码,这就是为什么你的应用程序运行正常,但调试器中的表达式计算器失败。



调试器总是试图读取它需要的最少量的调试信息,以便做任何你想要的。所以,直到你做一些事情,导致我们读入两个模块有不同的调试信息,你不会看到这个问题。这是为什么它有时会发生,有时不发生。



无论如何,请使用bugreporter.apple.com提交一个bug。


I'm trying to debug a C++ OS X application in XCode 5.1 (5B130a) under OS X 10.9.2. The application is composed of various library projects that get compiled into libraries and used in a main application project.

I set a breakpoint in my code and when I run in lldb:

expr 2

this is what I get:

   (lldb) expr 2
   error: field '__f_' declared with incompatible types in different translation units ('__base *' (aka 'std::__1::__function::__base<void (std::__1::shared_ptr<const XXX>, const YYY &)> *') vs. '__base *' (aka 'std::__1::__function::__base<void> *'))
error: field '__f_' declared with incompatible types in different translation units ('__base *' (aka 'std::__1::__function::__base<void (std::__1::shared_ptr<const XXX>, const YYY &)> *') vs. '__base *' (aka 'std::__1::__function::__base<void> *'))
error: expected expression
note: declared here with type '__base *' (aka 'std::__1::__function::__base<void> *')
note: declared here with type '__base *' (aka 'std::__1::__function::__base<void> *')
   error: 3 errors parsing expression

Please note that if I set the breakpoint somewhere else in the code, the same command might work (but not everywhere). This leads me to think that the specific library that I'm breaking in makes a difference.

I understand that somewhere there is a definition for std::function<void(std::shared_ptr<const XXX>, const YYY&)> and that some other translation unit sees it with a different definition, (I believe the __f_ is an internal field of the std::function templated class), however it's not clear to me:

  • why doesn't the linker complain about it? (in fact, the app is running perfectly)
  • what code generation switch mismatch could cause this? I already checked GCC_OPTIMIZATION_LEVEL (all -O0), COPY_PHASE_STRIP, ...

Thanks!

解决方案

This is most likely a problem with the debug information rather than with the generated code, which is why your app runs correctly but the expression evaluator in the debugger fails.

The debugger always tries to read the least amount of debug information it needs to in order to do whatever you ask it to. So until you do something that causes us to read in the two modules that have disagreeing debug information, you won't see this problem. That's why it sometimes happens and sometimes doesn't.

Anyway, please file a bug about this with bugreporter.apple.com.

这篇关于llvm报告用不兼容类型在不同翻译单元中声明的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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