什么是c ++ ABI? [英] what is c++ ABI?
问题描述
这就是我想要做的事情:
我正在为一个名为Symbian的操作系统编写程序,该操作系统使用gcc
编译器。
我有以下代码
class MyAllocator
{
};
class MyClass
{
public:
int i,j,k,l;
MyClass(){}
};
void * operator new [ ](size_t sz,MyAllocator *)
{
返回malloc(sz);
}
int main(int argc,char * argv [])
{
MyAllocator * pAlloc = new MyAllocator;
MyClass * pClass =新的(pAlloc)MyClass [3];
}
在Symbian上的
参数sz的值是56而在Windows上它的
48,为什么会这样?
我读到这对C ++ 0x ABI有所帮助,不确定它是什么意思......
任何解释?
问候
Chimanrao
This is what I am trying to do:
I am writing program for a OS called Symbian, which uses the gcc
compiler.
I have the following piece of code
class MyAllocator
{
};
class MyClass
{
public:
int i,j,k,l;
MyClass() {}
};
void * operator new [](size_t sz, MyAllocator *)
{
return malloc(sz);
}
int main(int argc, char *argv[])
{
MyAllocator *pAlloc = new MyAllocator;
MyClass *pClass = new(pAlloc) MyClass[3];
}
on Symbian the value for parameter sz is is 56 while on windows its
48, why is this?
I read that this has something to C++0x ABI, not sure what it means...
any explanations?
Regards
Chimanrao
Chimanrao写道:
Chimanrao wrote:
这就是我想要做的:
[。不同编译器上''new''的不同结果..]
我读到这有点C ++ 0x ABI,不知道它意味着什么...
This is what I am trying to do:
[.. different results of ''new'' on different compilers ..]
I read that this has something to C++0x ABI, not sure what it means...
ABI代表应用程序二进制接口,IIRC。
ABI stands for Application Binary Interface, IIRC.
任何解释?
any explanations?
见[expr.new] / 10。传递给新的大小可能大于
请求的大小。如果对象是一个数组。
V
-
请在回复时删除大写''A'电子邮件
我没有回复最热门的回复,请不要问
See [expr.new]/10. The size passed to ''new'' can be greater than the
"requested" if the object is an array.
V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask
任何解释?
any explanations?
>
见[expr.new] / 10。传递给新的大小可能大于
请求的大小。如果对象是一个数组。
>
See [expr.new]/10. The size passed to ''new'' can be greater than the
"requested" if the object is an array.
如果我删除了构造函数,那么new将被调用,大小为48.为什么
?
问候
Chimanrao
If i remove the constructor, then new gets called with size 48. Why is
that?
Regards
Chimanrao
main(int argc,char * argv [])
main(int argc, char *argv[])
{
MyAllocator * pAlloc = new MyAllocator;
MyClass * pClass = new(pAlloc)MyClass [3];
}
对于Symbian,
参数sz的值是56,而在windows上它的价格是
48,这是为什么?
{
MyAllocator *pAlloc = new MyAllocator;
MyClass *pClass = new(pAlloc) MyClass[3];
}
on Symbian the value for parameter sz is is 56 while on windows its
48, why is this?
根据你的硬件,int可能是8,16,32,64位长,假设
你不使用Symbian / Win同样的设备。另一个是
struct / class aligement,它可以在操作系统和编译器之间有所不同。
Depending on your hardware int could be 8,16,32,64 bits long, assuming
that you not using Symbian/Win on this same device. Another is
struct/class aligement which can differ between OS and compilers.
这篇关于什么是c ++ ABI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!