View previous topic :: View next topic |
Author |
Message |
Richi-d Guest
|
ERROR: Previous identifier must be a pointer |
Posted: Fri Jun 01, 2007 5:55 am |
|
|
With my old version 3.1xx my program ist compiling and running - with the new 4.xxx not. I read something about pointers...here is a part of my code, can anybody tell me whats wrong?
The error is the one in the headline...
char DATENZEILE[16];
void main()
{
strcpy (DATENZEILE, "Funktionstest ");
for (m = 0; m < 16; ++m)
{
delay_ms(1);
if (y_POS == 1)
{
output_d( 0x80 + m ); //Erste Zeile
output_low(R_S);
output_low(R_W);
output_high(ENABLE);
delay_us(10);
output_low(ENABLE);
}
if (y_POS == 2)
{
output_d( 0xC0 + m ); //Zweite Zeile
output_low(R_S);
output_low(R_W);
output_high(ENABLE);
delay_us(10);
output_low(ENABLE);
}
delay_ms(1);
output_d(DATENZEILE[m]);
output_high(R_S);
output_low(R_W);
output_high(ENABLE);
delay_us(10);
output_low(ENABLE);
}
}
} |
|
![](templates/subSilver/images/spacer.gif) |
inservi
Joined: 13 May 2007 Posts: 128
|
|
Posted: Fri Jun 01, 2007 7:11 am |
|
|
Hello,
Here is the sources formatted well with the tag “code”?
Code: |
char DATENZEILE[16];
void main(){
strcpy (DATENZEILE, "Funktionstest ");
for (m = 0; m < 16; ++m){
delay_ms(1);
if (y_POS == 1){
output_d( 0x80 + m ); //Erste Zeile
output_low(R_S);
output_low(R_W);
output_high(ENABLE);
delay_us(10);
output_low(ENABLE);
}
if (y_POS == 2){
output_d( 0xC0 + m ); //Zweite Zeile
output_low(R_S);
output_low(R_W);
output_high(ENABLE);
delay_us(10);
output_low(ENABLE);
}
delay_ms(1);
output_d(DATENZEILE[m]);
output_high(R_S);
output_low(R_W);
output_high(ENABLE);
delay_us(10);
output_low(ENABLE);
}
} |
The first thing is an unbalanced '}'
Then I added this arbitrary header before your code :
Code: |
#include <18F4685.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV45 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOIESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOPBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES BBSIZ4K //4K words Boot Block size
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#FUSES XINST //Extended set extension and Indexed Addressing mode enabled
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
int m, y_POS ;
#define R_S pin_A0
#define R_W pin_A0
#define ENABLE pin_A0
|
After that, it is compiled right with my V4.039.
Could-you give the line where the error occur ?
dro _________________ in médio virtus |
|
![](templates/subSilver/images/spacer.gif) |
Richi-d Guest
|
|
Posted: Fri Jun 01, 2007 10:18 am |
|
|
Hi,
What I posted is not the complete code- it´s clear that I have to declare the variables and so on...
The error occours in the
Code: | output_d(DATENZEILE[m]); |
line |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 01, 2007 10:30 am |
|
|
Quote: | with the new 4.xxx not. |
You need to post the exact version. |
|
![](templates/subSilver/images/spacer.gif) |
Richi-d Guest
|
|
Posted: Mon Jun 04, 2007 10:18 am |
|
|
The version now is PCH 4.018 |
|
![](templates/subSilver/images/spacer.gif) |
Richi-d Guest
|
|
Posted: Tue Jun 05, 2007 6:36 am |
|
|
Now I updated the compiler to the newest version- no change !! Has no one an answer?? Why does the code work with the old compiler 3.018? |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Jun 05, 2007 7:26 am |
|
|
Try to be exact!
For example always mention the version number, a reference to 'the newest version' is not something we can check as there are new releases almost every week.
Another example is that you said it is working in v3.1xx and now you mention the old working version is v3.018. This doesn't match, so again we can't check. Which was the working version?
You haven't posted a small and complete program that we can copy paste into our compiler. This leaves us to guessing. Inservi has been kind enough to extended your given code so it can be compiled and he didn't get the error. Have you tried compiling Inservi's code? Does that compile for you as well? Have you studied the differences in Inservi's code and your program?
Please remember that we are just users like you are. We are here to help each other but we are not going to do your work for you. You will get much better and quicker responses when you make it easy for us to reproduce your problem. For more hints and tips on how to post in this forum I suggest you read the sticky topic on top of this forum. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Jun 05, 2007 11:47 am |
|
|
Meanwhile I found the error-
This is wrong:
void Write_Display_Data_ZEILE ( y_POS, DATENZEILE )
This is right:
void Write_Display_Data_ZEILE ( y_POS )
It seams that the new version doesn`t allow to define the array"DATENZEILE" as global and to give it in the function additional.
[/code] |
|
![](templates/subSilver/images/spacer.gif) |
Richi-d Guest
|
|
Posted: Tue Jun 05, 2007 11:50 am |
|
|
But now I have a new problem: When the programm runs over this line:
Code: |
strcpy (DATENZEILE, "Kein Modul "); |
the Global Interrupt Bit is set to 0...
any ideas? |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Jun 05, 2007 12:14 pm |
|
|
Anonymous wrote: | Meanwhile I found the error-
This is wrong:
void Write_Display_Data_ZEILE ( y_POS, DATENZEILE )
This is right:
void Write_Display_Data_ZEILE ( y_POS )
It seams that the new version doesn`t allow to define the array"DATENZEILE" as global and to give it in the function additional. | Conclusion: We couldn't find the error because the error was in a part of your program that you didn't show us. This happens many times in this forum and that's why we ask again and again for a _complete_ example program showing your problem.
Quote: | But now I have a new problem: When the programm runs over this line:
Code:
strcpy (DATENZEILE, "Kein Modul ");
the Global Interrupt Bit is set to 0...
any ideas? | ..... where is the complete example program ???
From the little you have given us I can see one bug:
strcpy() copies the whole string up to and _including_ the terminating zero. Here you copy 17 characters to a 16 byte buffer. The buffer overflow will cause unpredictable errors. |
|
![](templates/subSilver/images/spacer.gif) |
Richi-d Guest
|
|
Posted: Tue Jun 05, 2007 2:15 pm |
|
|
I only count 16 characters, I tested it with:
Code: |
char DATENZEILE[17];
|
No change...
To your comments regarding missing code- I`m sorry, in this case it was relevant, but most time users list here 3 pages full of code- who has the time to study all this masses of information?
So I try to keep it short as possible. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 05, 2007 2:46 pm |
|
|
Quote: | But now I have a new problem: When the programm runs over this line:
strcpy (DATENZEILE, "Kein Modul ");
the Global Interrupt Bit is set to 0... |
This thread discusses the problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=25535 |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Sat Jun 09, 2007 1:49 pm |
|
|
I'm also getting this error "Previous identifier must be a pointer"
I'm running PCM 4.032
I have numerous arrays, but for some reason one is singled out for this error.
The variable is declared with global scope:
Code: | unsigned char MGTstatus[MAX]; |
Any references like these cause the error:
Code: |
MGTstatus[i] |= TIMEOUT;
if (MGTstatus[i] & SUPERVISORY) {}
|
Whereas these don't cause errors:
Code: |
*(MGTstatus+i) |= TIMEOUT;
if (*(MGTstatus+i) & SUPERVISORY) {}
|
Additionally, declaring a local corrects the error:
Code: |
unsigned char *statusMGT;
statusMGT = MGTstatus;
statusMGT[i] &= ~TIMEOUT;
|
I've made these edits to get my project to build for delivery by monday, but it's not pretty 8-(
I've tried declaring this array variable as a global, as a local to main, volatile, static, etc, it doesn't seem to matter.
I did elliminate the error from occurrences inside a #SEPERATE function that used it.
I made it an argument to the function and used a different name inside the function.
There were also changes in the error based on naming with leading capital letters.
This is quite odd, and more than a little unpleseant to have it occurr on a weekend when I'm pushing for delivery before monday.
Hopefully someone has sorted this all out.
Thanks for any help!
johnea |
|
![](templates/subSilver/images/spacer.gif) |
johnea
Joined: 09 Jun 2007 Posts: 2
|
|
Posted: Sat Jun 09, 2007 1:51 pm |
|
|
Somehow I managed to make the previous post without being logged in.
This reply is so I can get reply notice emails.
Thanks Again for any insight!!!
johnea |
|
![](templates/subSilver/images/spacer.gif) |
johnea
Joined: 09 Jun 2007 Posts: 2
|
|
Posted: Sun Jun 10, 2007 3:14 pm |
|
|
I uncovered the source of these difficulties.
There was a preprocessor symbol defined that only differed from the variable name in case: i.e.
Changing the variable name to differ from the preprocessor name fixed the error.
That's it for now...
johnea |
|
![](templates/subSilver/images/spacer.gif) |
|