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 4:43 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.
here is a sample code(its simple and short but its a good example of what I do):
Code:

#define jumper porta,0
int a,b,c,d;

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

void function1(){
     if(bit_test(jumper)
          a=6;
}

void main(){
     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.
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.....
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 is the compiler forbids me to do?
Is there any "IF statement" rulles that are different from the ANCI 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

PostPosted: Sun Jul 11, 2004 4:59 pm     Reply with quote

Here you go again for the 5th time! I am not mad at you either, but, as PCM told you earlier (http://www.ccsinfo.com/forum/viewtopic.php?t=18712), you need to contact CCS tech support.

We are not the CCS programmers and cannot fix this! Send them the example you gave and let them attack this. The only reason I can think of that you wouldn't contact CCS after all this is that you are using a pirated copy of the compiler. If it is a legal copy then they should help you. Otherwise, if it is not, we cannot help you so you have to just do whatever the compiler forces you to do to make it work since you indicate have already figured that out anyway.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Compiler generates endless loops
PostPosted: Sun Jul 11, 2004 8:06 pm     Reply with quote

This is just poor syntax.
Code:

#define jumper porta,0
     if(bit_test(jumper)


The efective way to get this done
Code:

#bit jumper porta,0
     if(jumper)


I'm not even sure what you expect the rest of your code to do. It's no wonder the compiler is confused.
chava



Joined: 07 Sep 2003
Posts: 56

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

that was an example
PostPosted: Mon Jul 12, 2004 12:21 am     Reply with quote

hello
First "dyeatman" :
I do have a legal registered copy of the pcb and pcm (3.174)

I am in contact with the CCS support and they did helped me last time, they opened my Ref# for about 2 weeks so that I can download other versions of the compiler, and I did.but is looks like it didnt helped.

Im here becouse I know that users of that compiler may have ecountered with this issue before and may help me with that.

I know that expirienced programers know the limits of theire compiler and find the things they have to avoid or how to do things in a better way.

this what the forum is all about, isnt it?
Why is this bodering you that I'm trying?
dyeatman



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

View user's profile Send private message

PostPosted: Mon Jul 12, 2004 7:33 am     Reply with quote

Chava,
OK, you asked....

What is bothering me (and a few other folks here) is that more than one person has already told you that we cant do you any good but you persist in posting the same thing over and over in the last four months.

When they tell me they can't help with a specific subject or I get no responses to a question, I dont keep asking over and over.

The only way this board will operate smoothly is for EVERYONE to observe courtesy and not clutter the board by re-asking questions that have already been answered in one form or another. More than 98% of the time my questions are answered by the search engine but for some reason many folks choose not to do a search on the internet and this forum before asking a question. For instance, using the search engine I found that your specific question had been asked four other times AND ANSWERED yet you persist! IMHO PCM is one of the (if not THE) most proficient CCS programmers here and when he tells you something it is a good bet to follow his advice. If in fact you did ask CCS then say so and indicate wht their response was. If they dont respond keep asking until they do. They are the official support channel not us.

As a professional programmer for the last 30 years I have to monitor four different programmers newsgroups and un-necessary questions being asked simply wastes forum space and time. You can be pretty certain that if anyone here has an answer to your question they would have provided it by the second or third time you asked.

I am done with this.....
chava



Joined: 07 Sep 2003
Posts: 56

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

Im sorry,
PostPosted: Mon Jul 12, 2004 12:01 pm     Reply with quote

Have a nice day
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