Re: Finding typecasts
Re: Finding typecasts
- Subject: Re: Finding typecasts
- From: "Sean McBride" <email@hidden>
- Date: Tue, 18 Aug 2009 17:43:04 -0400
- Organization: Rogue Research Inc.
On 8/18/09 5:23 PM, Dan White said:
>Depends how he did it.
>
>Did he cast ?
>
>int foo = (int)(pointer) ;
>
>or did he just "do it" implicitly ?
>
>int foo = pointer + 1 ?
>
>Strikes me that it would be very tough to automate finding either of
>those.
The latter is easy:
------
int main (int argc, char * const argv[])
{
void* foo = 0;
int bar = foo + 1;
return 0;
}
------
gcc-4.2 -Wall ~/Desktop/test.c
test.c:4: warning: initialization makes integer from pointer without a cast
The former is harder, because the cast is basically telling the compiler
to shut up. You could always search for "(int)". :9
If it were C++, you might search for static_cast or reinterpret_cast.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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