P
parag_paul
what are ABI'sin C++
-Parag
-Parag
what are ABI'sin C++
-Parag
On May 14, 10:16 am, "(e-mail address removed)" <[email protected]>
wrote:
Do you mean this?
They are at best peripheral to this news group, as they are
not part of the language standard. How the language connects
and communicates with the OS is not defined in any great
detail for C++.
James said:And it's a constant source of discussion: why
can't I link code compiled with Borland with code compiled with
Microsoft (which is possible for C)?
can't I link code compiled with Borland with code compiled with
Microsoft (which is possible for C)? In many ways, it's a
serious problem with C++ that the question doesn't have any
answers which would be really relevant here
A standardized ABI would allow even more than that. For example, it
would allow linking object files created by compilers of different
languages into the binary (such as for example object files created by a
pascal compiler).
Btw, isn't the .NET framework some kind of attempt to do exactly that,
ie. being able to call libraries made in any language from another language?
Which is why I was so damn disappointed when I knew that the TR1
didn't even consider the ABIs. Truly a shame IMO.
A standardized ABI would allow even more than that. For
example, it would allow linking object files created by
compilers of different languages into the binary (such as for
example object files created by a pascal compiler).
Btw, isn't the .NET framework some kind of attempt to do
exactly that, ie. being able to call libraries made in any
language from another language?
The reason is simple: any API must be platform specific (at
least given current technology). There's no way code that I
compile on my Sun Sparc can be made to run on a PC. Thus,
languages which don't depend on a virtual machine can't define
a standard API. For that matter, even languages like Java,
which do define one (through JVM), tend to consider it separate
from the language standard: the specification of the Java
language doesn't specify an API, and the specification of JVM
doesn't specify the language used to compile to it.
As has been frequently pointed out, JVM is actually a platform,
like Windows on a PC. And it is the platform which should
define the API (which should apply to all of the programming
languages on the platform). The current situation is that most
platforms do define an API, but without many of the elements
needed for C++. So each compiler extends the platform API in a
different way. If I use C or Fortran, I can link code compiled
with the Sun compiler with code compiled with the GNU compiler.
If I use C++ (or Ada, I think), I can't. The problem isn't with
the C++ or Ada language standard, but with Sun's standard for
Solaris.
Where?Fernando said:But AFAIK, C does define an ABI.
I don't actually notice what the API has to do with the ABI, or why an
ABI has to be plataform specific.
But AFAIK, C does define an ABI.
I don't actually notice what the API has to do with the ABI,
or why an ABI has to be plataform specific.
Well, the ABI for C on a Sparc, under Solaris, says that the
first five arguments go into the registers o0-o4, at least if
they are int's or pointers. That's going to be a little bit
hard to implement on an Intel, which doesn't have as many
registers (and above all, doesn't manage them at all in the same
manner).
Ok, I think then that I had a wrong concept of an ABI. I thought it
was all about mangling and calling conventions.
Tim said:It is. ABI has nothing to do with crossing platform boundaries. It's
a standard, well-defined way of doing things like name mangling,
calling conventions, argument passing, alignment, etc. It is usually
defined per hardware platform, and smart OSes follow it. So in the
end, an object file built by g++ can be linked with an object file
built by Sun CC, on the same platform.
Ah, you appear to be contradicting your earlier statement here.C++ does not have that. I can't even guarantee to be able to link
against objects from a different version of the same compiler!
It is. ABI has nothing to do with crossing platform boundaries. It's
a standard, well-defined way of doing things like name mangling,
calling conventions, argument passing, alignment, etc. It is usually
defined per hardware platform, and smart OSes follow it. So in the
end, an object file built by g++ can be linked with an object file
built by Sun CC, on the same platform. If you do it right, you can
link objects across languages on the same platform. If you're really
good you can link objects across OSes (e.g. SCO vs BSD vs Linux).
C++ does not have that. I can't even guarantee to be able to link
against objects from a different version of the same compiler!
Any arguments about linking sparc and x86 code are red herrings.
Tim
Fernando said:So, if we take away all the politics surrounding the standardization
process of C++, it'll be possible to define an ABI for C++, won't it?
Ok, I think then that I had a wrong concept of an ABI. I
thought it was all about mangling and calling conventions.
On May 16, 3:23 pm, Fernando Gómez <[email protected]>
wrote:
It is. ABI has nothing to do with crossing platform
boundaries. It's a standard, well-defined way of doing things
like name mangling, calling conventions, argument passing,
alignment, etc. It is usually defined per hardware platform,
and smart OSes follow it. So in the end, an object file built
by g++ can be linked with an object file built by Sun CC, on
the same platform.
If you do it right, you can link objects across languages on
the same platform. If you're really good you can link objects
across OSes (e.g. SCO vs BSD vs Linux).
C++ does not have that. I can't even guarantee to be able to
link against objects from a different version of the same
compiler!
Any arguments about linking sparc and x86 code are red
herrings.
Fernando said:Ok, I think then that I had a wrong concept of an ABI. I thought it
was all about mangling and calling conventions.
Juha said:A standardized ABI would allow even more than that. For example, it
would allow linking object files created by compilers of different
languages into the binary (such as for example object files created by a
pascal compiler).
Btw, isn't the .NET framework some kind of attempt to do exactly that,
ie. being able to call libraries made in any language from another
language?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.