Who said that you should?
Who said that you should?
Please cite and quote the passage from the ANSI/ISO C++ standard
that *guarantees* that "it works fine".
C functions compiled by one compiler need not be callable
from programs compiled with any other compiler --
not even another C compiler.
The only way to guarantee that you can call C functions
from a C++ program is to compile them with the *same* C++ compiler.
Wrong. My C programs are using different functions in different
libraries compiled with compilers I've never seen. The truth is that
you have to define clearly the calling conventsions and interfaces you
should use. Anything else is definded by the liner - and not part of
the C language or the compiler itself.
I've used gcc to call functions in libraries written definitely with
IBM VAc++, and with Watcom. I use Watcom C to call fuctions in
libraries written with the C compiler of IBM VA C++ and GCC. I use the
C compiler in IBM VA C++ to call functions in libraries written with
other compilers.
I use even som functions definitely written in COBOL, fortran and
other languages. Some of them written in pure assembler too. But look,
the libraries are designed to have interfaces to most commonly used
languages - and for all C compilers - even such NOT existent at the
day the libraries were released.
A C compiler is designed to produce binaries, ready prepared to get
linked with a linker of your choice. An binary of a well designed
system is well designed to be understandable by any linker this system
environment knows or will known in forseable future.
You may link object module together to build an executeable program or
by inserting an interface module to build a library callable by any
language. Has nothing to do with the programming language you use to
write something in source.
The way from a source compilation unit to an executeable program or an
library is long. A C compiler is only starting point to get the source
translated into some kind of binary (or source) module that needs to
be handled by one or more other programs.
Me and thousends of other peoples have written programs in C who are
NOT understandable by any C compiler without passing another kind of
compiler prior, needing some different compilers of different sources
too to be linked separately, then commonly then again to get an
library that can linked at runtime to another program alreard exist to
extend its functionality on the fly.