C ++ sizeof类型在库和调用代码中有所不同 [英] C++ sizeof type different in library and calling code

查看:62
本文介绍了C ++ sizeof类型在库和调用代码中有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在可可粉应用程序中使用C ++库.我从macOS应用程序C ++代码中调用C ++库代码.我遇到库中的客户端类返回的问题

I use C++ library in cocoa application. And I call C++ library code from macos application C++ code. I run into problem that Client class in library returns

sizeof Client 976

但是在Mac OS应用程序中我有

but in Mac OS application I have

sizeof Client 944

客户端类 https://github.com/eiskaltdcpp/eiskaltdcpp/blob/master/dcpp/Client.h

那是为什么?

推荐答案

在比较了客户端类之后,我去了它的父类,发现父类(扬声器)的一个成员(CriticalSection)引起了大小上的差异.

After comparetion of Client classes i went to it parent class and found that one member (CriticalSection) of parent class (Speaker) cause this difference of size.

在该文件的标题中,我发现由于未定义宏,Mac OS应用程序使用了此类的不同定义(CriticalSection),这会导致大小差异.

In header of this file i found that because of not defined macros Mac OS application use different definition of this class(CriticalSection) which cause difference of size.

这篇关于C ++ sizeof类型在库和调用代码中有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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