CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Compiler generates endless loops

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chava



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message Send e-mail

Compiler generates endless loops
PostPosted: Sun Jul 11, 2004 5:18 pm     Reply with quote

Hello
I am sort of new to ccs compiler, and the reason is that :
I get an asignment from my bos, I've got some amount of time to finish it,
I sit and plan a nice little C program and I write it, as I know C, and then when I compile it, I realize that the compiler generates endless loops, here and there - while my code does not contains any loops.
then, since Im faceing a death-line, I give up, and turn back to assembler where I have more control over the code.

here is a sample code(its simple and short but its a good example of what I do):
Code:

int a,b,c,d;

void initiate(){
     a=5;
     b=5;
     c=5;
     d=5;
}

void function1(){
     if(bit_test(porta,0))
          a=6;
}

void main(){
     while(1){
          initiate();
          function1();
     }
}

When I add The "IF" statement, the code stuck in endless loop between "a=5;" to "c=5;"(for example)
when I dont add the "IF" statement, there is no loop, and the program runs as requested....(strange, isnt it???)

when I open the program memory window (in mplab ide) I find that actualy, an endless loop was created between those commands.
I found that the return from the function"initiate()" makes "goto" without changing the page-select bits. the address of the "goto" is correct- but in another page of the memory....
today I tryed for several houres to find how to skip this problem then I made the initiate() function "ONLINE" and the problem was solved.....
but this is not a good solution: in that case the function is been called only once, so I dont care putting it online, but if it is a function which I use several times in the program, its a problem....



something else happened , in a nother ocasion, when I did:
Code:

if(a==1){
     if(b==2)
          c=3;
     b=4;
}

and the code ignored the "d=4;, it didnt do it(I run some tests)
only when I did:
Code:

if(a==1){
     b=4;
     if(b==2)
          c=3;
}

it worked good, which is not good, becouse this is not what I wanted.....

So, what can you tell me about this?
what does the compiler forbids me to do?
Is there any "IF statement" rulles that are different from the ANCII C rules?
I tryed to add braces to every If like that:
Code:

if(a==1){
     b=4;
     if(b==2){
          c=3;
     }
}

but it did'nt helped?
can anyone help me?
It became so ridiculouse - that I waste a lot of time on manipulating the code to "FIT" the compiler so that it will do what I asked it to do in simple C lines....
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

Are we going to do this from now on????
PostPosted: Sun Jul 11, 2004 6:34 pm     Reply with quote

Here you go again for the 6th time!

I repeat again, and as PCM told you earlier, ASK CCS!!!!

Send them the example you gave and let them attack this. You evidently are using a pirated copy of the compiler. If you are, then you are getting EXACTLY what you paid for. If not, then CCS is the only one who can help so quit asking us!!

WE ARE NOT CCS AND CANNOT FIX THIS!!!
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Jul 11, 2004 7:33 pm     Reply with quote

Chava,

You are having these same problems now for 4 months. It could very well be a compiler bug, almost nobody is using the PCB version so you might be the first one to notice. You are using an old version of the compiler, many problems have been solved since.

Have you reported your problem to CCS? What was the CCS response?

Don't you think it's time to ask your boss for a CCS Maintenance contract?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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