DSPRelated.com
Forums

Re: Re: [c6x] strange problem while not prototyping!!

Started by tArAng May 5, 2004

Hi Khalida,

You are absolutely correct .. when I tried to return a float .. without prototyping that function .. i got some junk value. (Non repeatable junk)..
Then i prototyped it and got the correct float value as I shud get.

Thanks a lot for ur comment.

Best Regards,

Tarang Dadia

On Sun, 02 May 2004 K...@aol.com wrote :
>In a message dated 5/1/2004 4:59:48 PM Eastern Daylight Time,
>t...@rediffmail.com writes:
>Hi All,
>I just bumped across this strange thing by mistake. Dont know exactly why
>this is happening.
>
>The thing is I am writing couple of functions in different file (other than
>where my main is) . I am including this file to my project folder and calling
>those functions. No where am I prototyping the functions, its just a
>definition.  Even in the main file I am not including the function file its just in the
>same project . Compiler or the linker doesnt throw any errors or anything. And
>still the functions are being called and executed properly. Its not a problem
>to me, I  m just curious as to how did it take care of not prototyping it and
>not declaring it as extern and stuff.
>
>Just to make more sense out of my writing , kindly follow the pseudo-code.
>Hi Tarang,
>    BE VERY careful of the not prototyping your functions in CCS!!!  This a
>big bug that took weeks of investigation in my code to figure out.  When you
>don't prototype, the compiler is assuming default parameters.  For example, if
>your unprototyped function returns a float, the compiler will assume an integer
>return value.  Try this with one of your unprototyped functions and change it
>to return a float value, especially a fraction, and assign the returned value
>to some float variable in your calling function (main in your case).  Build
>your project and step through your code.  Step into your unprototyped function,
>check the value it is about to return, now step out of it and check if it is
>the same.  I bet you its not!  If it turns out, please let us know your
>finding for benefit of the group.
>
>    Now I think the compiler can be set so it will be more strict and check
>for prototypes and generate an error if it finds unprototyped function calls
>(force ANSI C checking?).  Unfortunately CCS default setup is without this
>restriction, so we are exposed to this danger in our projects, unless we take care
>of it by prototyping always.
>
>Regards,
>/Khalid




Hi all,

I've had this problem as well, and found a useful compiler switch to
help. If you add '-pdr' you'll get remarks from the compiler
highlighing the 'implicit declaration' of those unprototyped
functions. I think the c-standard assumes integer if not
prototyped. I hooked on '-pdr' now - which has saved me a lot of
time since!

raj

--- In , "tArAng" <tarangdadia@r...> wrote:
> Hi Khalida,
>
> You are absolutely correct .. when I tried to return a float ..
without prototyping that function .. i got some junk value. (Non
repeatable junk)..
> Then i prototyped it and got the correct float value as I shud get.
>
> Thanks a lot for ur comment.
>
> Best Regards,
>
> Tarang Dadia >
>
> On Sun, 02 May 2004 KHALIDA1@a... wrote :
> >In a message dated 5/1/2004 4:59:48 PM Eastern Daylight Time,
> >tarangdadia@r... writes:
> >Hi All,
> >I just bumped across this strange thing by mistake. Dont know
exactly why
> >this is happening.
> >
> >The thing is I am writing couple of functions in different file
(other than
> >where my main is) . I am including this file to my project folder
and calling
> >those functions. No where am I prototyping the functions, its
just a
> >definition. Even in the main file I am not including the
function file its just in the
> >same project . Compiler or the linker doesnt throw any errors or
anything. And
> >still the functions are being called and executed properly. Its
not a problem
> >to me, I m just curious as to how did it take care of not
prototyping it and
> >not declaring it as extern and stuff.
> >
> >Just to make more sense out of my writing , kindly follow the
pseudo-code.
> >Hi Tarang,
> > BE VERY careful of the not prototyping your functions in
CCS!!! This a
> >big bug that took weeks of investigation in my code to figure
out. When you
> >don't prototype, the compiler is assuming default parameters.
For example, if
> >your unprototyped function returns a float, the compiler will
assume an integer
> >return value. Try this with one of your unprototyped functions
and change it
> >to return a float value, especially a fraction, and assign the
returned value
> >to some float variable in your calling function (main in your
case). Build
> >your project and step through your code. Step into your
unprototyped function,
> >check the value it is about to return, now step out of it and
check if it is
> >the same. I bet you its not! If it turns out, please let us
know your
> >finding for benefit of the group.
> >
> > Now I think the compiler can be set so it will be more
strict and check
> >for prototypes and generate an error if it finds unprototyped
function calls
> >(force ANSI C checking?). Unfortunately CCS default setup is
without this
> >restriction, so we are exposed to this danger in our projects,
unless we take care
> >of it by prototyping always.
> >
> >Regards,
> >/Khalid


Hey Raj,

Thanx a lot for ur comment. It would be great if you can tell me what does -pdr do. Or else gimme a pointer where to look to.. Best Regards,
Tarang On Thu, 03 Jun 2004 dspnuts wrote :
>Hi all,
>I've had this problem as well, and found a useful compiler switch to
>help.  If you add '-pdr' you'll get remarks from the compiler
>highlighing the 'implicit declaration' of those unprototyped
>functions.  I think the c-standard assumes integer if not
>prototyped.  I hooked on '-pdr' now - which has saved me a lot of
>time since!
>raj
>--- In c...@yahoogroups.com, "tArAng" <tarangdadia@r...> wrote:
>> Hi Khalida,
>>
>> You are absolutely correct .. when I tried to return a float ..
>without prototyping that function .. i got some junk value. (Non
>repeatable junk)..
>> Then i prototyped it and got the correct float value as I shud get.
>>
>> Thanks a lot for ur comment.
>>
>> Best Regards,
>>
>> Tarang Dadia
>>
>>
>>
>>
>> On Sun, 02 May 2004 KHALIDA1@a... wrote :
>> >In a message dated 5/1/2004 4:59:48 PM Eastern Daylight Time,
>> >tarangdadia@r... writes:
>> >Hi All,
>> >I just bumped across this strange thing by mistake. Dont know
>exactly why
>> >this is happening.
>> >
>> >The thing is I am writing couple of functions in different file
>(other than
>> >where my main is) . I am including this file to my project folder
>and calling
>> >those functions. No where am I prototyping the functions, its
>just a
>> >definition.  Even in the main file I am not including the
>function file its just in the
>> >same project . Compiler or the linker doesnt throw any errors or
>anything. And
>> >still the functions are being called and executed properly. Its
>not a problem
>> >to me, I  m just curious as to how did it take care of not
>prototyping it and
>> >not declaring it as extern and stuff.
>> >
>> >Just to make more sense out of my writing , kindly follow the
>pseudo-code.
>> >Hi Tarang,
>> >    BE VERY careful of the not prototyping your functions in
>CCS!!!  This a
>> >big bug that took weeks of investigation in my code to figure
>out.  When you
>> >don't prototype, the compiler is assuming default parameters.
>For example, if
>> >your unprototyped function returns a float, the compiler will
>assume an integer
>> >return value.  Try this with one of your unprototyped functions
>and change it
>> >to return a float value, especially a fraction, and assign the
>returned value
>> >to some float variable in your calling function (main in your
>case).  Build
>> >your project and step through your code.  Step into your
>unprototyped function,
>> >check the value it is about to return, now step out of it and
>check if it is
>> >the same.  I bet you its not!  If it turns out, please let us
>know your
>> >finding for benefit of the group.
>> >
>> >    Now I think the compiler can be set so it will be more
>strict and check
>> >for prototypes and generate an error if it finds unprototyped
>function calls
>> >(force ANSI C checking?).  Unfortunately CCS default setup is
>without this
>> >restriction, so we are exposed to this danger in our projects,
>unless we take care
>> >of it by prototyping always.
>> >
>> >Regards,
>> >/Khalid
>_____________________________________
>Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.
>_____________________________________
>About this discussion group:
>To Join:  c...@yahoogroups.com
>To Post:  c...@yahoogroups.com
>To Leave: c...@yahoogroups.com
>Archives:
>http://www.yahoogroups.com/group/code-comp
>More Groups:
>http://www.dsprelated.com
>
>Yahoo! Groups Links
>To BR> >.
>



Tarang,
 
I use the compiler user guide in general for these bits.
 
http://focus.ticom/lit/ug/spru187k/spru187k.pdf
 
and programmers guide
 
http://focus.ticom/lit/ug/spru198g/spru198g.pdf
 
In this case, there's not a huge amount of detail on specifics of '-pdr', other than that this causes the compiler to issue remarks (non-serious warnings).  I find these really useful and you can always switch them off once you are happy.
 
Regards,
raj
----- Original Message -----
From: tArAng
To: dspnuts
Cc: c...@yahoogroups.com
Sent: Thursday, June 03, 2004 3:39 AM
Subject: Re: [code-comp] Re: [c6x] strange problem while not prototyping!!

Hey Raj,

Thanx a lot for ur comment. It would be great if you can tell me what does -pdr do. Or else gimme a pointer where to look to..Best Regards,
TarangOn Thu, 03 Jun 2004 dspnuts wrote :
>Hi all,
>I've had this problem as well, and found a useful compiler switch to
>help.  If you add '-pdr' you'll get remarks from the compiler
>highlighing the 'implicit declaration' of those unprototyped
>functions.  I think the c-standard assumes integer if not
>prototyped.  I hooked on '-pdr' now - which has saved me a lot of
>time since!
>raj
>--- In c...@yahoogroups.com, "tArAng" <tarangdadia@r...> wrote:
>> Hi Khalida,
>>
>> You are absolutely correct .. when I tried to return a float ..
>without prototyping that function .. i got some junk value. (Non
>repeatable junk)..
>> Then i prototyped it and got the correct float value as I shud get.
>>
>> Thanks a lot for ur comment.
>>
>> Best Regards,
>>
>> Tarang Dadia
>>
>>
>>
>>
>> On Sun, 02 May 2004 KHALIDA1@a... wrote :
>> >In a message dated 5/1/2004 4:59:48 PM Eastern Daylight Time,
>> >tarangdadia@r... writes:
>> >Hi All,
>> >I just bumped across this strange thing by mistake. Dont know
>exactly why
>> >this is happening.
>> >
>> >The thing is I am writing couple of functions in different file
>(other than
>> >where my main is) . I am including this file to my project folder
>and calling
>> >those functions. No where am I prototyping the functions, its
>just a
>> >definition.  Even in the main file I am not including the
>function file its just in the
>> >same project . Compiler or the linker doesnt throw any errors or
>anything. And
>> >still the functions are being called and executed properly. Its
>not a problem
>> >to me, I  m just curious as to how did it take care of not
>prototyping it and
>> >not declaring it as extern and stuff.
>> >
>> >Just to make more sense out of my writing , kindly follow the
>pseudo-code.
>> >Hi Tarang,
>> >    BE VERY careful of the not prototyping your functions in
>CCS!!!  This a
>> >big bug that took weeks of investigation in my code to figure
>out.  When you
>> >don't prototype, the compiler is assuming default parameters. 
>For example, if
>> >your unprototyped function returns a float, the compiler will
>assume an integer
>> >return value.  Try this with one of your unprototyped functions
>and change it
>> >to return a float value, especially a fraction, and assign the
>returned value
>> >to some float variable in your calling function (main in your
>case).  Build
>> >your project and step through your code.  Step into your
>unprototyped function,
>> >check the value it is about to return, now step out of it and
>check if it is
>> >the same.  I bet you its not!  If it turns out, please let us
>know your
>> >finding for benefit of the group.
>> >
>> >    Now I think the compiler can be set so it will be more
>strict and check
>> >for prototypes and generate an error if it finds unprototyped
>function calls
>> >(force ANSI C checking?).  Unfortunately CCS default setup is
>without this
>> >restriction, so we are exposed to this danger in our projects,
>unless we take care
>> >of it by prototyping always.
>> >
>> >Regards,
>> >/Khalid
>_____________________________________
>Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.
>_____________________________________
>About this discussion group:
>To Join:  c...@yahoogroups.com
>To Post:  c...@yahoogroups.com
>To Leave: c...@yahoogroups.com
>Archives:
>http://www.yahoogroups.com/group/code-comp
>More Groups:
>http://www.dsprelated.com
>
>Yahoo! Groups Links
>To BR>>.
>



inbox.htm@Bottom

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:  c...@yahoogroups.com

To Post:  c...@yahoogroups.com

To Leave: c...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/code-comp

More Groups: http://www.dsprelated.com


Raj-

> I use the compiler user guide in general for these bits.
>
> http://focus.ticom/lit/ug/spru187k/spru187k.pdf
>
> and programmers guide
>
> http://focus.ticom/lit/ug/spru198g/spru198g.pdf
>
> In this case, there's not a huge amount of detail on specifics of
> '-pdr', other than that this causes the compiler to issue remarks
> (non-serious warnings). I find these really useful and you can
> always switch them off once you are happy.

I would advise *always* keeping all warnings and remarks enabled. Anything at
all
that catches your eye could save you hours later. If a particular non-serious
warning is supposed to be there, and you don't want to keep seeing it, you can
suppress just that one by giving the warning number.

-Jeff