• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Extern "C" -- Function Parameters Corrupted on Mactel??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extern "C" -- Function Parameters Corrupted on Mactel??


  • Subject: Extern "C" -- Function Parameters Corrupted on Mactel??
  • From: Ben Weiss <email@hidden>
  • Date: Thu, 18 May 2006 00:14:02 -0700

I'm running into a bizarre situation trying to combine C and C++ code as follows:

File: stuff.h:

extern "C" long Test2(long x, float y);

File: stuff.cpp:

long Test2(long x, float y) { return x + (long)y; } // or whatever

File: main.c:

long Test1(long x, float y) { return Test2(x, y); }


Inside Test1, the values for x and y are correct (say, 16 and 4, respectively)... but when Test2 is entered, the value of y is corrupted! (usually 0 or 1.0e-45 or something.) This is not just a debugger issue; in my actual project the corrupted value causes downstream code to crash.


The same code works perfectly on PowerPC; it only has this problem on Mactel, and only with floating-point parameters. Is there a compiler bug here, or am I overlooking something obvious?

Thanks,
Ben
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Extern "C" -- Function Parameters Corrupted on Mactel??
      • From: Eric Albert <email@hidden>
  • Prev by Date: Re: dead-code stripping, pass two...
  • Next by Date: Re: Extern "C" -- Function Parameters Corrupted on Mactel??
  • Previous by thread: Re: Switching from -O3 to -Os causes my code to start crashing
  • Next by thread: Re: Extern "C" -- Function Parameters Corrupted on Mactel??
  • Index(es):
    • Date
    • Thread