Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
November 24, 2017, 10:37:29 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Exercise 13-7 ? undefined behavior???  (Read 2236 times)
mdeh
Full Member
***
Posts: 166


« on: February 01, 2009, 06:38:15 AM »

Steve,
Although NSString is not yet formally covered, I wonder about the one definition given in the exercise ie

NSString *format = "x = %i";

It produces a warning on my : warning: initialization from incompatible pointer type

I **think**?? this is expected, as this assigns a C type string whereas an NSString type is expected?  Is this the realm of undefined behavior and can any output from this be valid, even though it **does** seem to produce the expected result? SEE BELOW

It is not further used in the exercise, although the statement

"NSLog(@"%s", format);" seems to be accepted by the compiler (output:  x = %i)

Also note, the integer x is unused in the exercise.



« Last Edit: February 01, 2009, 08:15:14 AM by mdeh » Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: February 03, 2009, 06:10:43 AM »

Quote
Although NSString is not yet formally covered, I wonder about the one definition given in the exercise ie

NSString *format = "x = %i";

It produces a warning on my : warning: initialization from incompatible pointer type

Yes, that line should be deleted from the exercise (and it's incorrect to boot!).

« Last Edit: February 03, 2009, 12:39:11 PM by skochan » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.