- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 youLink Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page