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 2683
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...@com Acast.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.c omwrote:
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*******@gmai l.comwrote in message
news:11******** **************@ 22g2000hsm.goog legroups.com...
On Oct 9, 5:05 am, jg <jgu...@gmail.c omwrote:
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.c omwrote:
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 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 burns.
Here is the code:
$frank = "burns";
|
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 any preconceived ideas about it. I have
noticed, however, that every programmer I talk to who's aware of Python is
also talking about Ruby. So it seems that Ruby has the potential to compete
with and displace Python. I'm curious on what basis it...
|
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 capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
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?
cheers,
reed
|
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 pragmatic
- 3) I usually move forward when I get the gut feeling I am correct
- 4) Most likely because of 1), I usually do not manage to fully explain 3)
when it comes true.
- 5) I have developed for many years (>18) in many different environments,...
| |
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 {
public:
string desc;
|
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 software giant such as Microsoft SQL
Server, Oracle, and Sybase?
Is PostgreSQL reliable enough to be used for high-end commercial
application? Thanks
|
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 support IDEs are DreamWeaver 8 and
Zend PHP Studio.
DreamWeaver provides full support for Unicode. However, DreamWeaver is
a web editor rather than a PHP IDE. It only supports basic IntelliSense
(or code completion) and doesn't have anything...
|
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 basically entitled to us to just about
every .Net development tool you can imagine. I cant even begin to mention
them.
To begin with, my background is not that of a programmer, but a systems
engineer and the closest I have come to "programming"...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |