Author Topic: Identifier is undefined error in keil  (Read 10932 times)

0 Members and 1 Guest are viewing this topic.

Offline dizgahTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: 00
Identifier is undefined error in keil
« on: November 16, 2014, 06:59:24 am »
hi every one
as i said past im trying to port osama GLCD library to keil for using with stm32f103 mcu
i am using prevlet variable in a glcd_putchar function but keil shows :
Quote
identifer"prevlet" is undefined
& its while that im declare this variale as global variable
Code: [Select]
unsigned char prevLet = 193;
is there any one for helping me?
i attached source code too & thanks
Happiness can be found, even in the darkest of times, if one only remembers to turn on the light.
Albus Dumbledore
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Identifier is undefined error in keil
« Reply #1 on: November 16, 2014, 07:04:39 am »
hi every one
as i said past im trying to port osama GLCD library to keil for using with stm32f103 mcu
i am using prevlet variable in a glcd_putchar function but keil shows :
Quote
identifer"prevlet" is undefined
& its while that im declare this variale as global variable
Code: [Select]
unsigned char prevLet = 193;
is there any one for helping me?
i attached source code too & thanks


prevLet is not the same as prevlet you used lowercase l somewhere instead of L.

Also next time attach the code in here it does accepts zips under attachments and other options right under where you type your message.

I didn't look at your code because filetolink wants me to sign in via google, facebook or yahoo and of course I won't do that even if I had one of those accounts.


 

Offline dizgahTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: 00
Re: Identifier is undefined error in keil
« Reply #2 on: November 16, 2014, 07:33:13 am »
tnks for your answer
both of them are
Quote
prevLet
& differences was about my typing fault
i attached it again(becouse forum dose not accept .rar format & zip format will be more than 1MB i compress in zip & then zip the rar file )
« Last Edit: November 16, 2014, 07:35:06 am by dizgah »
Happiness can be found, even in the darkest of times, if one only remembers to turn on the light.
Albus Dumbledore
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Identifier is undefined error in keil
« Reply #3 on: November 16, 2014, 07:55:29 am »
Seems to me the problem is in font.h

prevLet in glcd.h is the frist statement after that include and other defines and inside font.h you have some control characters within the file and the compiler thinks the file ends early because of those control characters.

Any reason you have to leave those control characters within the file instead of just a description?

I mean you can just put the letters BEL for character 7 instead of the actual bell control character in the source.

Or SUB in line 30 (where it complains) instead of the actual 0x1a control character in the comment at the end of line 30.


Code: [Select]
compiling main.c...
..\lib\font.h(30): warning:  #1-D: last line of file ends without a newline
..\lib\font.h(1): error:  #37: the #endif for this directive is missing
  #ifndef Font_Lib
..\lib\glcd.h(45): error:  #29: expected an expression
  unsigned char prevLet = 193;
..\lib\glcd.h(45): error:  #67: expected a "}"
  unsigned char prevLet = 193;
..\lib\glcd.h(688): error:  #20: identifier "prevLet" is undefined
          if((c >= 193) && (prevLet >= 193) && (map[prevLet-193][5]) && (map[c-193][4]))
..\lib\glcd.h(688): error:  #20: identifier "map" is undefined
          if((c >= 193) && (prevLet >= 193) && (map[prevLet-193][5]) && (map[c-193][4]))
..\lib\glcd.h(759): error:  #20: identifier "prevLet" is undefined
     prevLet = 193;
..\lib\main.c: 1 warning, 6 errors
".\gpio.axf" - 6 Error(s), 1 Warning(s).
« Last Edit: November 16, 2014, 07:58:17 am by miguelvp »
 

Offline dizgahTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: 00
Re: Identifier is undefined error in keil
« Reply #4 on: November 16, 2014, 08:38:33 am »
Seems to me the problem is in font.h

prevLet in glcd.h is the frist statement after that include and other defines and inside font.h you have some control characters within the file and the compiler thinks the file ends early because of those control characters.

Any reason you have to leave those control characters within the file instead of just a description?

I mean you can just put the letters BEL for character 7 instead of the actual bell control character in the source.

Or SUB in line 30 (where it complains) instead of the actual 0x1a control character in the comment at the end of line 30.


Code: [Select]
compiling main.c...
..\lib\font.h(30): warning:  #1-D: last line of file ends without a newline
..\lib\font.h(1): error:  #37: the #endif for this directive is missing
  #ifndef Font_Lib
..\lib\glcd.h(45): error:  #29: expected an expression
  unsigned char prevLet = 193;
..\lib\glcd.h(45): error:  #67: expected a "}"
  unsigned char prevLet = 193;
..\lib\glcd.h(688): error:  #20: identifier "prevLet" is undefined
          if((c >= 193) && (prevLet >= 193) && (map[prevLet-193][5]) && (map[c-193][4]))
..\lib\glcd.h(688): error:  #20: identifier "map" is undefined
          if((c >= 193) && (prevLet >= 193) && (map[prevLet-193][5]) && (map[c-193][4]))
..\lib\glcd.h(759): error:  #20: identifier "prevLet" is undefined
     prevLet = 193;
..\lib\main.c: 1 warning, 6 errors
".\gpio.axf" - 6 Error(s), 1 Warning(s).
really thanks dear miguelvp
it seems you are right
the reason i ignoring these warning are i think they are comment & compiler dosent attention to comment(altough im confused how comment can do error :? )
--------
i cant find thanks button,where is it ?
--------
tnks again, i will come back soon with sack of new errors & warnings ; )
Happiness can be found, even in the darkest of times, if one only remembers to turn on the light.
Albus Dumbledore
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Identifier is undefined error in keil
« Reply #5 on: November 16, 2014, 08:40:48 am »
It's not the comments doing errors, those are special control characters that don't belong in the source code, it doesn't matter if they are in the comments or not, but they are going to throw the compiler off.

 

Offline dizgahTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: 00
Re: Identifier is undefined error in keil
« Reply #6 on: November 16, 2014, 02:41:18 pm »
hi again
here i have a new error too :(
Quote
symbol font multiply defined
&
Quote
symbol map multiply defined
its as ,i used #ifndef # def preprocessor instructions & dont know reason of this error,i attached my program in keil & hope some body help me in doing this
tnks again
Happiness can be found, even in the darkest of times, if one only remembers to turn on the light.
Albus Dumbledore
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Identifier is undefined error in keil
« Reply #7 on: November 16, 2014, 04:16:23 pm »
That is because font is defined and initialized in GLCD.h. This way font will be inside the scope of the C file where #include "GLCD.h" is processed first.
Note that the header guards are not working in the scope of the next C file. They are there to prevent header include loops.
Move the definition of font to the C file, and use "extern const unsigned char font[]" inside the header. That is, if you want it to be public.

It probably doesn't need to be public, since it's for the GLCD lib itself, put it at the top of GLCD.c and don't put it in the header.
You can force it to throw an error when it is externally linked by putting static in front. This also applies to functions.

Same goes for map.
« Last Edit: November 16, 2014, 04:25:33 pm by Jeroen3 »
 

Offline dizgahTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: 00
Re: Identifier is undefined error in keil
« Reply #8 on: November 17, 2014, 12:40:59 pm »
hi every body again
thanks Jeroen3
----------------
i eliminated all of errors,program compiled correctly but it dosent affect on lcd(lcd dosent show any thing)
i debug it in keil & it seems instructions dosent affect to gpio ,for example gpio_config or setbit/reset bit & others dosent work (i dont see change in GPIOC debugging section)
ex cuse me but can any one please see code & help me again ?
WBR
Happiness can be found, even in the darkest of times, if one only remembers to turn on the light.
Albus Dumbledore
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Identifier is undefined error in keil
« Reply #9 on: November 17, 2014, 01:32:10 pm »
Verify with a oscilloscope or logic analyzer that:
- you have configured the GPIO, and pin multiplexers correctly. And power/clock to gpio blocks obviously.
- the EN signal is emitted with the correct timing (those displays are slow)
 

Offline dizgahTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: 00
Re: Identifier is undefined error in keil
« Reply #10 on: November 17, 2014, 02:01:18 pm »
Verify with a oscilloscope or logic analyzer that:
- you have configured the GPIO, and pin multiplexers correctly. And power/clock to gpio blocks obviously.
- the EN signal is emitted with the correct timing (those displays are slow)
thank Jeroen3
i dosent have oscope or logic analyzer   :-[
any way i see it dosent work correctly in keil debugging/simulating section

timing is correct too becouse this library work fine in avr & codevision & even avrgcc
i want to know gpio instructions work correctly becouse im doubt it
 :-BROKE
Happiness can be found, even in the darkest of times, if one only remembers to turn on the light.
Albus Dumbledore
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Identifier is undefined error in keil
« Reply #11 on: November 17, 2014, 02:43:38 pm »
Quote
timing is correct too becouse this library work fine in avr & codevision & even avrgcc
An STM32F1 is faster than an AVR. Much faster.

I am not aware of actual simulation features in Keil, I do know the debug mode. Did you try to step through the code in debug mode and measure with your DMM what the IO state is?
You can also put LED's on the bus and put a breakpoint in you trigger function.

A Saleae logic analyzer clone can be bought for under $30.
 

Offline dizgahTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: 00
Re: Identifier is undefined error in keil
« Reply #12 on: November 17, 2014, 03:35:54 pm »
Quote
timing is correct too becouse this library work fine in avr & codevision & even avrgcc
An STM32F1 is faster than an AVR. Much faster.

I am not aware of actual simulation features in Keil, I do know the debug mode. Did you try to step through the code in debug mode and measure with your DMM what the IO state is?
You can also put LED's on the bus and put a breakpoint in you trigger function.

A Saleae logic analyzer clone can be bought for under $30.
about timing i mean parameters are same for example i used 1us delay as used in avr lib
DMM ? whats meaning of it ?
LED is a good solution i will do it
thanks
Happiness can be found, even in the darkest of times, if one only remembers to turn on the light.
Albus Dumbledore
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Identifier is undefined error in keil
« Reply #13 on: November 19, 2014, 06:54:39 am »
1 us is only enough to do a bus read operation.
The fastest write commands available are all 38 micro seconds (us) in execution time. During that, the LCD won't respond.
The slowest command is the Clear Display, with 1.5 milliseconds (ms).

1 us is the value for the EN pulse with, which is allowed to be as low as 250 nanoseconds (ns).
A delay of 250 ns on the chip does not mean a 250 ns pulse width on the other side of the bus cable.

*values taken from typical hd44780 2x16 display datasheet I've used*
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf