I've tried putting suffix 'y' followed by binary numbers within an array in header file but "syntax error near 'y', expected '}' " appear. Kindly ignore the first array of the attachment.
Yes, of course, it's a header file, it's not the main program. It's just for definition of some bit mapped array variables. And yes I've tried unsigned char data type also. If you have keil installed perhaps you can try and solve it with just one array in the header file and a main c program file to call it.
I don't have Keil installed but extern means it defined in another C file. Get rid of the extern and move it into the main C file and it should compile.
The way extern works is you define it in another C file and use it in the current file... If you define in a header and call said header then the word extern must be omitted..
Thank you all for taking your time.. but all the fixes you have mentioned are known to me and aren't the issues, works fine with decimal numbers. My concern is to write array of binary numbers like
Code:
unsigned char A[]={ 01101100, 00110110}
. In keil binay specifier is 'y' as suffix and '0' as prefix is octal specifier. So if I write
Code:
01101100y
there's a conflict for compiler whether the number is binary or octal. So I can't find other ways to specify binary numbers followed by zero. That's what I want a solution to...
In my case using hex is better than using decimal but then again for my project I need binary map of 8by8 matrix. And I tried using '0b' prefix, didn't work.
In my case using hex is better than using decimal but then again for my project I need binary map of 8by8 matrix. And I tried using '0b' prefix, didn't work.
the 0 (zero) prefix is only an octal indicator if no suffix is present. If a Y suffix is present, it is binary.
Also, try with no leading zeros in your binary if it is not working with leading zero. If neither work, then you have some issue with other code.