[comp.sys.mac.programmer] external C fcns from MPW C++

marc@Apple.COM (Mark Dawson) (02/24/91)

I've run into a problem when trying to call a C function from my C++ code--I
don't know how to tell C++ that this is a C function:

void x()
  {
     Boolean IsItThere();   // my external C fcn
     if (IsItThere())
       DoIt();
  }
The Linker complains because it can't find "IsItThere__Fv".  I know that I
can do :
extern "C" {
  Boolean IsItThere();
  Boolean WasItThere();
}
But this doesn't seem to work when declaring the function from inside a 
a function.

Is what I want to do possible?  If it is, how can you do it?

Thanks,  
Mark

-- 
---------------------------------
Mark Dawson                Service Diagnostic Engineering
AppleLink: Dawson.M

Apple says what it says; I say what I say.  We're different
---------------------------------

anders@verity.com (Anders Wallgren) (02/24/91)

Well, if it doesn't matter to you where you declare the function (I
don't see why it should), then you could do:

extern "C" {
     Boolean IsItThere();   // my external C fcn
}

void x()
  {
     if (IsItThere())
       DoIt();
  }


"IsItThere__Fv" is the C++-type-safe-linkage-munged version of
"IsItThere"

anders

snow@elbereth.rutgers.edu (Rob Hsu) (02/28/91)

anders@verity.com (Anders Wallgren) writes:

> Well, if it doesn't matter to you where you declare the function (I
> don't see why it should), ...

	Apparently, link specifications cannot appear inside function
definitions.  (Refer to page 6-14 of the _Selected Readings_ volume
of the AT&T documentation).

----------
Rob Hsu