hi,
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 10 2652
Chimanrao wrote:
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 stands for Application Binary Interface, IIRC.
any explanations?
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?
>
See [expr.new]/10. The size passed to 'new' can be greater than the
"requested" if the object is an array.
If i remove the constructor, then new gets called with size 48. Why is
that?
Regards
Chimanrao
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?
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.
Chimanrao wrote:
>>any explanations?
See [expr.new]/10. The size passed to 'new' can be greater than the "requested" if the object is an array.
If i remove the constructor, then new gets called with size 48. Why is
that?
Ask the compiler/library manufacturer. It's not specified by the
language whether the size is going to be dependent on the constructor
or what the overhead is going to be. Not specified. IOW, there is
no way to answer your "why" question, except by saying "the compiler
and/or the library designer had the need to do that".
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On Oct 8, 10:06 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Chimanrao wrote:
>any explanations?
See [expr.new]/10. The size passed to 'new' can be greater than the
"requested" if the object is an array.
If i remove the constructor, then new gets called with size 48. Why is
that?
Ask the compiler/library manufacturer. It's not specified by the
language whether the size is going to be dependent on the constructor
or what the overhead is going to be. Not specified. IOW, there is
no way to answer your "why" question, except by saying "the compiler
and/or the library designer had the need to do that".
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Can this be related to POD, non-POD types. With the constructor its a
non-POD type, but with the constructor its a POD Type.
Visual Studio and g++ did not differentiate.
Regards
Chimanrao
I read that this has something to C++0x ABI, not sure what it means...
any explanations?
How to layout a class is part of ABI. And the layout of a class
decides how many bytes a class will consume.
JG
On Oct 9, 5:05 am, jg <jgu...@gmail.comwrote:
I read that this has something to C++0x ABI, not sure what it means...
any explanations?
How to layout a class is part of ABI. And the layout of a class
decides how many bytes a class will consume.
JG
Cool, is this compiler specific or does the standard mandate this?
Regards
Chimanrao
"Chimanrao" <ch*******@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
On Oct 9, 5:05 am, jg <jgu...@gmail.comwrote:
I read that this has something to C++0x ABI, not sure what it means...
any explanations?
How to layout a class is part of ABI. And the layout of a class decides how many bytes a class will consume.
Cool, is this compiler specific or does the standard mandate this?
It is compiler/OS specific how many bytes any given class/structure will
contain because there are varying sizes of types between compilers/OSes.
Alignment issues may also be different, as well as if they do lookup tables
for functions, etc...
On 2007-10-09 05:29, Chimanrao wrote:
On Oct 9, 5:05 am, jg <jgu...@gmail.comwrote:
I read that this has something to C++0x ABI, not sure what it means...
any explanations?
How to layout a class is part of ABI. And the layout of a class decides how many bytes a class will consume.
JG
Cool, is this compiler specific or does the standard mandate this?
Usually platform specific (ABI that is) the layout of members is
probably the same on the for most OSes running on the same hardware
since it is limited by the hardware.
--
Erik Wikström
Erik Wikström wrote:
On 2007-10-09 05:29, Chimanrao wrote:
>On Oct 9, 5:05 am, jg <jgu...@gmail.comwrote:
>>>I read that this has something to C++0x ABI, not sure what it means... any explanations? How to layout a class is part of ABI. And the layout of a class decides how many bytes a class will consume.
JG
Cool, is this compiler specific or does the standard mandate this?
Usually platform specific (ABI that is) the layout of members is
probably the same on the for most OSes running on the same hardware
since it is limited by the hardware.
The ABI is very much compiler specific. One of the bug bears of C++ for
desktop application and window managers is lack of ABI compatibility
between compilers.
C programmers have it easy!
--
Ian Collins. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: thecrow |
last post by:
Alright, what the hell is going on here?
In the following code, I expect the printed result to be:
DEBUG: frank's last name is burns.
Instead, what I get is:
DEBUG: frank's last name is...
|
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro...
|
by: Reed L. O'Brien |
last post by:
I see rotor was removed for 2.4 and the docs say use an AES module
provided separately... Is there a standard module that works alike or
an AES module that works alike but with better encryption?...
|
by: Philippe C. Martin |
last post by:
I apologize in advance for launching this post but I might get enlightment
somehow (PS: I am _very_ agnostic ;-).
- 1) I do not consider my intelligence/education above average
- 2) I am very...
|
by: Dario |
last post by:
The following simple program behaves differently
in Windows and Linux .
#include <stdexcept>
#include <iostream>
#include <string>
using namespace std;
class LogicError : public logic_error {...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from...
|
by: Neal |
last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog
entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A
quite good article.
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode...
|
by: Midnight Java Junkie |
last post by:
Dear Colleagues:
I feel that the dumbest questions are those that are never asked. I have
been given the opportunity to get into .NET. Our organization has a
subscription with Microsoft that...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |