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

Assigning two 16bit unsigned integers problem

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



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

Assigning two 16bit unsigned integers problem
PostPosted: Sat Dec 15, 2018 3:12 am     Reply with quote

Hello friends. İ have a problem about assigning 16bit unsigned int to another. When i compile the program i have 2 errors. Please help me.

https://media.discordapp.net/attachments/514062526565318658/523426203454144523/Adsz.png?width=841&height=473
Ttelmah



Joined: 11 Mar 2010
Posts: 19550

View user's profile Send private message

PostPosted: Sat Dec 15, 2018 4:28 am     Reply with quote

In each expression, one of the variables doesn't actually exist.
It could be either.

Remember a variable _only_ exists inside the function it is declared 'in',
unless you declare it outside any function, when it becomes 'global'.

So, since 'deger' exists inside the same function a few lines above, it has to
be 'keyit_1', and 'keyit_2', which either have not been declared at all, or
are declared somewhere which is making them not actually exist at this point.
Ömer Faruk



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

PostPosted: Sat Dec 15, 2018 6:28 am     Reply with quote

Ttelmah wrote:
In each expression, one of the variables doesn't actually exist.
It could be either.

Remember a variable _only_ exists inside the function it is declared 'in',
unless you declare it outside any function, when it becomes 'global'.

So, since 'deger' exists inside the same function a few lines above, it has to
be 'keyit_1', and 'keyit_2', which either have not been declared at all, or
are declared somewhere which is making them not actually exist at this point.


Thanks for your reply.
İ define kayit_1 , kayit_2 and deger as global variables. İ didn't use them in any function except deger. İ used deger in an external interrupt.
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 15, 2018 6:47 am     Reply with quote

I'm wondering if it's a 'case' problem ?
You've got KAYIT_1 and kayit_1 in your code.
CCS defaults to 'no case', so both names may refer to the same variable.
I KNOW I've been caught by this in the past...... Sad

Without seeing the whole program it is difficult to debug
Jay
Ömer Faruk



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

PostPosted: Sat Dec 15, 2018 7:05 am     Reply with quote

temtronic wrote:
I'm wondering if it's a 'case' problem ?
You've got KAYIT_1 and kayit_1 in your code.
CCS defaults to 'no case', so both names may refer to the same variable.
I KNOW I've been caught by this in the past...... Sad

Without seeing the whole program it is difficult to debug
Jay


You are definetly right. Thank you very much. But ccs c language is case sensitive. Why this happens i dont understand.
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 15, 2018 7:55 am     Reply with quote

It's ONLY case sensitive IF you add #CASE at the beginning of your code.
The default is NOT case so 'this', 'THIS',' ThIs','tHIs', 'thiS' are all the same and reference one RAM location.

Since you only posted part of your code, I assumed you didn't add #CASE, so the compiler would use noCASE.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19550

View user's profile Send private message

PostPosted: Sat Dec 15, 2018 1:09 pm     Reply with quote

Another thing that can cause this issue, is having something else with the
same name. If (for instance), you have a #define that also uses 'kayit_1',
then the declaration won't actually happen. So:
#define kayit_1 something

then

int16 kayit_1;

doesn't result in kayit_1 being declared. Instead 'something' gets declared.

Now depending on what 'something' is, this may not be a possible
declaration, so then things go wrong....

Similarly using the same name in an enum, can also give problems.
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