Re: Newbie: No Problems, Program compiles and works, but it has warnings
Re: Newbie: No Problems, Program compiles and works, but it has warnings
- Subject: Re: Newbie: No Problems, Program compiles and works, but it has warnings
- From: Matthew D Hancher <email@hidden>
- Date: Thu, 06 Nov 2003 21:19:12 -0500
I don't have the book and hence the source, but it here's what it
looks like from the compiler output. There is a method in Controller.m
called -ltob which is defined on line 124 but is used before then, on
line 91 in the method -displayX. You should either declare the method
in the class's interface (in Controller.h) or move the definition of
-ltob prior to the definition of -displayX.
The reason this doesn't cause any run-time troubles is that when you use
the -ltob method without declaring it, the compiler assumes it returns an
integer result. In this case the actual return value is a pointer, but
pointers and integers are treated the same way on most architectures so
nothing bad actually happens. This is nevertheless not portable and is
definitely a bug in the code.
Matt
George Greene <email@hidden> wrote:
>
I'm using Mac OS X 10.2.8, Project Builder Version 2.1 Component
>
versions
>
PB IDE:114.0 PB Core: 1120 ToolSupport:110.
>
>
The settings for Project Builder are the defaults, I changed nothing
>
when I first started the program.
>
>
In following the book, "Building Cocoa Application Step by Step",
>
Chapter 7, Delegation and Resizing, page 220, page 221, I get the
>
following warnings.
>
>
warning: implicit declaration function 'ltob'
>
warning: assignment makes pointer from integer without a cast
>
warning: type mismatch with previous implicit declaration
>
warning: previous implicit declaration of 'lbod'
>
warning: 'ltob' was previously implicitly declared to return 'int'
>
Build succeeded (5 warnings)
>
>
>
/usr/bin/gcc3 -c -F/Users/gmg/Calculator/build
>
-I/Users/gmg/Calculator/build/include -arch ppc -fno-common
>
-fpascal-strings -O0 -Wmost -Wno-four-char-constants
>
-Wno-unknown-pragmas -pipe "-fmessage-length=0" -mdynamic-no-pic -g
>
-Wp,-header-mapfile,/Users/gmg/Calculator/build/Calculator.build/
>
Calculator.build/Calculator.hmap --load-pch
>
/Users/gmg/Calculator/build/Calculator.build/Calculator.build/
>
PrefixHeaders/Calculator_Prefix-ppc.pfe Controller.m -o
>
/Users/gmg/Calculator/build/Calculator.build/Calculator.build/Objects-
>
normal/ppc/Controller.o
>
Controller.m: In function `-[Controller displayX]':
>
Controller.m:91: warning: implicit declaration of function `ltob'
>
Controller.m:91: warning: assignment makes pointer from integer without
>
a cast
>
Controller.m: At top level:
>
Controller.m:124: warning: type mismatch with previous implicit
>
declaration
>
Controller.m:91: warning: previous implicit declaration of `ltob'
>
Controller.m:124: warning: `ltob' was previously implicitly declared to
>
return `int'
>
>
The program runs fine, as far as I can tell.
>
>
I'm curious, how would I correct the program so that no warnings show
>
up.
>
>
Thanks,
>
>
george.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.