Amazon.com Widgets Exercise 13-7 ? undefined behavior???
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 26, 2014, 04:09:59 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Errata
| | |-+ 1st & 2nd printings
| | | |-+ Exercise 13-7 ? undefined behavior???
Pages: [1] Go Down
Print
Author Topic: Exercise 13-7 ? undefined behavior??? (Read 1273 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:



Login with username, password and session length

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 (c) 2009 classroomM.com. All rights reserved.