patches for Sun Forte 7/8 compilers

Stefan Teleman steleman at nyc.rr.com
Mon Nov 3 23:35:24 GMT 2003


Here's a little test:

#include <iostream>
using namespace std;

// extern "C" {
void foo (int size)
{
    cerr << "foo (int size): size = " << size << endl;
}

void foo (int size, const char* name)
{
    cerr << "foo (int size, const char* name): name = " << name
         << " size = " << size << endl;
}
// }

int
main (int argc, char* argv[])
{
     int size = 3;
     const char* name = "Bob";

     foo (size);
     foo (size, name);
     return (0);
}

-----

if you compile it with "extern C" commented out, it works like a 
peach:

[steleman at starwars][~/tmp][11/03/2003 18:34:25][2414]>> !CC
CC testFoo.C -o testFoo
[steleman at starwars][~/tmp][11/03/2003 18:34:31][2415]>> ./testFoo 
foo (int size): size = 3
foo (int size, const char* name): name = Bob size = 3
[steleman at starwars][~/tmp][11/03/2003 18:34:34][2416]>>

now, if you uncomment the "extern C" stuff:

[steleman at starwars][~/tmp][11/03/2003 18:35:19][2418]>> !CC
CC testFoo.C -o testFoo
"testFoo.C", line 11: Error: Only one of a set of overloaded functions 
can be extern "C".
"testFoo.C", line 10: Error: foo(int, const char*) and foo(int) have 
same extern name "foo".
2 Error(s) detected.
[steleman at starwars][~/tmp][11/03/2003 18:35:22][2419]>>

--Stefan

-----

On Monday 03 November 2003 17:58, Guillaume Laurent wrote:
> On Monday 03 November 2003 23:20, Oswald Buddenhagen wrote:
> > i know all this, but i still don't get it. sigaction just takes a
> > pointer to a function that takes certain arguments. is the
> > compiler allowed to do weird things to the argument list if the
> > linkage is not "C", or what?
>
> AFAIK C linkage just means the function's name won't be mangled
> (and of course overloading and default arg values are not
> possible).

-- 
Stefan Teleman          'Nobody Expects the Spanish Inquisition'
steleman at nyc.rr.com                          -Monty Python





More information about the kde-core-devel mailing list