|
|
View previous topic :: View next topic |
Author |
Message |
Rose Guest
|
log( ) |
Posted: Fri Feb 21, 2003 3:56 am |
|
|
Hello!
Is there anybody once had the problem of calling log()?
I'm using PCW IDE3.2, PCB,PCM,PCH 3.112, and Windows2000. Whenever I call log(), the compiler will give out a "Access violation......" warning message. I had included math.h in the beginning.
What's wrong with it? Give me some clue, if possible.
Thanks,
___________________________
This message was ported from CCS's old forum
Original Post ID: 11948 |
|
|
R.J.Hamlett Guest
|
Re: log( ) |
Posted: Fri Feb 21, 2003 6:06 am |
|
|
:=Hello!
:=
:=Is there anybody once had the problem of calling log()?
:=
:=I'm using PCW IDE3.2, PCB,PCM,PCH 3.112, and Windows2000. Whenever I call log(), the compiler will give out a "Access violation......" warning message. I had included math.h in the beginning.
:=
:=What's wrong with it? Give me some clue, if possible.
:=
:=Thanks,
What chip?.
Give the actual calling line.
Shouldn't be any problem at all. It suggests perhaps something odd in the settings, or calling syntax, that is actually generating the fault. There were some 'arithmetic' problems with log, back in the early 3.x compilers, but these appeared as faults in the values, rather than compiler errors.
The sort of thing I am thinking about, is that you perhaps have a #define, or a function definition, that conflicts with part of math.h
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 11950 |
|
|
Rose Guest
|
Re: log( ) |
Posted: Fri Feb 21, 2003 8:45 am |
|
|
Thanks very much for your post!
The chip is PIC18F242/252.
Part of the code is listed following.
#include <math.h>
...
main(){
float Resistor,Resistor1;
....
Resistor1=Resistor/4700;
Resistor=log(Resistor1);
...
}
Which type of a function definition may conflict with part of math.h? And which #define can cause it?
The reason should be one of the above two, because I just put this log() into another c file, and it works. No "Access Violation ... "again. The only differece is other parts of the program. Fortunately, the program which didn't work is only a test program. The one I tried later and successful is exact program going to call log().
Best Regards,
Rose
___________________________
This message was ported from CCS's old forum
Original Post ID: 11958 |
|
|
R.J.Hamlett Guest
|
Re: log( ) |
Posted: Sat Feb 22, 2003 6:02 am |
|
|
:=Thanks very much for your post!
:=
:=The chip is PIC18F242/252.
:=Part of the code is listed following.
:=#include <math.h>
:=...
:=main(){
:=float Resistor,Resistor1;
:=....
:=
:= Resistor1=Resistor/4700;
:= Resistor=log(Resistor1);
:=...
:=}
:=
:=Which type of a function definition may conflict with part of math.h? And which #define can cause it?
:=
The same as allways applies. Any function or define, that could be mistaken by the compiler. Remember that by default the compiler has case significance turned off, and that there will be a limit on the length of labels that is considered 'significant' (I can't remember what it is for the CCS compiler). Generally this leads to problems like:
void my_maths_function(void)
and
void my_maths_addition(void)
being seen as the same, since in a lot of cases significance is only eight characters. Hence look through maths.h and see if anything might be mistaken this way.
My own suspicion would be one of the 'critical' defines for the log function (LN2, LN10, or LOG10), being used somewhere else, and leading to a problem...
Worth also being careful with the declaration of constants. In the example above, the division 'Resistor/4700', results in the integer 4700, being used, and explicitly converted to a float. In general this is safe, but on the CCS compiler, at times such implicit conversions have in the past caused unexpected results. Hence using either:
Resistor/(float)4700
or
Resistor/4700.0
May well be safer.
Best Wishes
:=The reason should be one of the above two, because I just put this log() into another c file, and it works. No "Access Violation ... "again. The only differece is other parts of the program. Fortunately, the program which didn't work is only a test program. The one I tried later and successful is exact program going to call log().
:=
:=
:=Best Regards,
:=
:=Rose
___________________________
This message was ported from CCS's old forum
Original Post ID: 11995 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|