We have this declaration in LCD.c:
unsigned char LCD[8][64] = {((unsigned char) 0)};
And in LCD.h we want to have something like:
extern unsigned char LCD[][];
We get this error:
Error[Pe098]: an array may not have elements of this type
We have this declaration in LCD.c:
unsigned char LCD[8][64] = {((unsigned char) 0)};
And in LCD.h we want to have something like:
extern unsigned char LCD[][];
We get this error:
Error[Pe098]: an array may not have elements of this type
You need, at a minimum, to include the right-most column size for a 2-D array. You can declare it like this:
extern unsigned char LCD[][64];
Otherwise the compiler would not be able to compute the offset after the first row.
In C an array does not contain information about the size of each one of its dimensions. Therefore, the compiler needs to know how large is each one of the dimensions except the first one. So, to correct this situation, do something like this:
LCD.h:
#define MINOR 64
extern unsigned char LCD[][MINOR];
LCD.c:
unsigned char LCD[8][MINOR] = {((unsigned char)0)};
(EDIT: sorry, I messed up things in the beginning, fixed it now.)
Try specifying the dimensions of the array. In C for a multidimensional array only one dimension can be left unspecified.
Like this:
extern unsigned char LCD[][64];
With multidimensional arrays, all but the first dimension must be specified. So...
extern unsigned char LCD[][64];
Should do it.
Add to the header file a declaration like:
extern unsigned char LCD[8][64];
sizeof of LCD array will refused if you didn't define the size of the two dimension !
sizeof refused : extern unsigned char LCD[][64];
sizeof accepted : extern unsigned char LCD[8][64];
it depend what you want !
#include using namespace std;
int main(){
int n;
cout<<"Enter The Number"<<endl;
cin>>n;
int m;
cout<<"Enter The Second Number"<<endl;
cin>>m;
int array[n][m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin<<array[i][j]<<endl;
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cout<<array[i][j]<<" ";
}
cout<<endl;
}
return 0; }
© 2022 - 2024 — McMap. All rights reserved.
#include "LCD.h"
intoLCD.c
(soMINOR
macro is defined only once in header file) in order to exclude possibility of conflicting types forLCD
between declaration and actual definition (which is not detected as compilation error when they are in different files and linker error as well). – Ng