• 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
Re: Problem using static floats
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem using static floats


  • Subject: Re: Problem using static floats
  • From: "Shawn Erickson" <email@hidden>
  • Date: Thu, 19 Jul 2007 11:08:23 -0700

On 7/18/07, Joel Norvell <email@hidden> wrote:

I can see that the float value is not passed correctly into MyWidget but the int value is. (Both worked correctly on the PowerBook.) I think this may be a byte ordering problem in floats. Is there an X-code setting that affects this?

The following is an (contrived) example of what I think you are getting hit by. If you compile the following you see the warnings...

/Users/serickson/DecIssue/DecIssue.m:19: warning: no '+floatValue' method found
/Users/serickson/DecIssue/DecIssue.m:19: warning: (Messages without a
matching method signature
/Users/serickson/DecIssue/DecIssue.m:21: warning: no '+setFloatValue:'
method found
/Users/serickson/DecIssue/DecIssue.m:22: warning: no '+floatValue' method found
/Users/serickson/DecIssue/DecIssue.m:25: warning: no '+floatValue' method found

...and the output will be other then you expect simple because the
compile doesn't see the declaration for some of the methods and
assumes id to be the type...

2007-07-19 11:05:41.883 DecIssue[21367] 1) 1.000000 1.000000 0.000000
2007-07-19 11:05:41.883 DecIssue[21367] 2) 0.000000 0.000000 0.000000
2007-07-19 11:05:41.883 DecIssue[21367] 3) 3.000000 3.000000 0.000000

#import <Foundation/Foundation.h>

static float value;

@class MissedDeclaration;
@class VisibleDeclaration;

@interface VisibleDeclaration : NSObject {
}
+ (void) setValue:(float)inValue;
+ (float) value;
@end

int main (int argc, const char * argv[]) {
   value = 0.0;

   [VisibleDeclaration setValue:1.0];
   NSLog(@"1) %f %f %f", value, [VisibleDeclaration value],
[MissedDeclaration floatValue]);

   [MissedDeclaration setFloatValue:2.0];
   NSLog(@"2) %f %f %f", value, [VisibleDeclaration value],
[MissedDeclaration floatValue]);

   [VisibleDeclaration setValue:3.0];
   NSLog(@"3) %f %f %f", value, [VisibleDeclaration value],
[MissedDeclaration floatValue]);

   return 0;
}

@interface MissedDeclaration : NSObject {
}
+ (void) setFloatValue:(float)inValue;
+ (float) floatValue;
@end

@implementation VisibleDeclaration
+ (void) setValue:(float)inValue
{
   value = inValue;
}

+ (float) value
{
   return value;
}
@end

@implementation MissedDeclaration
+ (void) setFloatValue:(float)inValue
{
   value = inValue;
}

+ (float) floatValue
{
   return value;
}
@end
_______________________________________________
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


References: 
 >Problem using static floats (From: Joel Norvell <email@hidden>)

  • Prev by Date: Java, XCode, CodeSense, code completion woes continued
  • Next by Date: Re: Xcode class functions auto-complete not working in 2.4.1?
  • Previous by thread: Re: Problem using static floats
  • Next by thread: Re: Problem using static floats
  • Index(es):
    • Date
    • Thread