Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers

about niosII

Altera_Forum
Honored Contributor II
1,512 Views

Hi, 

I write in NiosII this instruction  

int a,b; 

int r; 

a=4; 

b=98; 

r=a&&b; 

the problem i have a message error ,when i use && ,I don't know why ? 

can sameone help me to use this commande && ? 

thank you
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
507 Views

The sintax is correct. 

What's the compiler error message? 

PS: I'd recommend spaces to separate && symbol (logical AND); although this is not mandatory, it will improve code readability.
0 Kudos
Altera_Forum
Honored Contributor II
507 Views

i try with espace but i have the some error 

this a part of code of erode  

 

int **IM ,**im1; 

unsigned char r,u,ml,mm,mr,d; 

for(int i=1;i<height-1;i++){ 

for(int j=1;j<width-1;j++) 

u = im1[i-1][j]; 

ml = im1[j-1];  

mm = im1[j];  

mr = im1[j+1]; 

d = im1[i+1][j]; 

r= (u && d) && (ml && mr && mm); 

im[j]=r 

}} 

this code turn witn succes under visual c++ but under nios II a i have this error: expected unqualified-id before  

processeur failed
0 Kudos
Altera_Forum
Honored Contributor II
506 Views

 

--- Quote Start ---  

 

for(int i=1;i<height-1;i++){ 

for(int j=1;j<width-1;j++) 

 

--- Quote End ---  

 

You can't define variables inside the for loop instruction.  

This mode is not supported by Nios C compiler. 

Declare i and j with other variables. 

 

 

--- Quote Start ---  

 

int **IM ,**im1; 

 

--- Quote End ---  

 

IMHO this declaration is ambiguous if you then use these pointers to address a bidimensional array. 

You don't specify dimensions, so, how can compiler know how to map array indexes to memory? 

 

 

--- Quote Start ---  

 

IM[i][j]=r 

 

--- Quote End ---  

 

Semicolon missing 

 

Regards 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
507 Views

defining variables in for loops is legal in C++, but not in C. Visual isn't a 100% compliant C compiler and sometimes lets you do non standard things ;) 

 

The biggest problem with this code is that you use the IM and im1 pointers without assigning them a proper value first. This will probably crash in most cases. 

You should define static arrays instead.
0 Kudos
Reply