We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, i'm using Keil Evaluation Boards to program my STM32F4Discovery. I was wondering, why can't I use boolean or bit type data? Or it's because i'm using the Evaluation version? I want to use "true" or "false" value, maybe i can use another type data besides that two buddies? I'll be happy and glad if anybody can help me with this one. Sorry for my bad english...
Investigate stdbool.h and structure bitfields.
Wow, it works! Thank you for your big help. I put "stdbool.h" in my code and write "bool" as a data type for my variabel. Thank you.
Does 'bool' really save any data memory? more specifically, does 'bool' allocate/reserve one bit memory in ram or it reserves 1byte, but the compiler ensures that only one bit data is written to those variables?
Got the answer. for bool type variables, the size is 8bits i.e. 1byte. hence, bool in ARM is not same as bool on x51 architecture.
structures & bit padding can be done instead of 'bool'
On c51 it's a bit type that only has one bit of storage allocated.
Why not Please read the manual? Dumbass.
If at the pompous pretentious gits were burnt, one pompous pretentious git would still remain in the ashes.
Dumbass Really?? What amount of experience you got working on controllers?
And on x51 architecture, if bool is 1byte, i would really want to check for different tool chain. IMO, a bool & bit should occupy same amount of memory.
"IMO, a bool & bit should occupy same amount of memory."
Except for the tiny little fact that the C language doesn't have any 1-bit data type, and the same is true for most microprocessors. The bit field construct is just a grammatical work-around to hide a lot of AND/OR machine code instructions, so while it may save RAM space, it still consumes way more code space than what is needed by a 8051 processor that can actually read and write individual bits.
it still consumes way more code space than what is needed by a 8051 processor i totally agree. either save code at the cost of ram or vice-versa.
but some (over)smart people dont realize the fact that 7bits should not be wasted for what can be done in 1bit.
i have come across situations where people have written code using a lot of ram (unnecessarily) and then have altered a lot of code or written a lot of extra code just to create more space in ram. imho, precaution is better than cure.
You must learn. On this forum, nothing should be deduced from the posters name!
It's anyone's guess as to who is really replying to another poster or just themself.
I remember at least one case where a 'better regarded' poster admitted to having done it. tut-tut.
Proper registration needs to be implemented to stop the tiresome joke.
And there are a lot of spamsters also who advertise about 'video convertors' 'dvd convertors' etc. Unfortunately keil site development engineers have turned deaf ears to this (and many more) issue(s).
Well, a couple of times every year they also run out of disk space, in which case people who posts either locks up threads or totally fails to post. Keil knows about this but ignores the badwill from it regularly repeating.
IMO, a bool & bit should occupy same amount of memory.
Why?
And on x51 architecture, if bool is 1byte, i would really want to check for different tool chain.
Keil's C51 isn't C99 compliant and doesn't support the bool (_Bool) type anyway.
It does, however, have an extension for the bit type. Careful use of this facility can help produce space and time efficient code.
Just realised the guy's name and the paraphrase. Now it makes sense.
why Well, bool is generally used for storing & checking true/false or 1/0. Logically, for storing only 2 values, 1 binary bit is enough.
Controllers have low on-chip ram memory & hence external memory is interfaced. If an engineer (having only on-chip ram) misuses ram memory (and doesn't know how to reduce ram usage or use it efficiently), then he may either have to modify hardware or modify software after getting stuck up or compromise on the features of the embedded device he is writing the software for. now-a-days the controllers (generally) dont have bit/byte addressible area as in x51.
Well, bool is generally used for storing & checking true/false or 1/0. Logically, for storing only 2 values, 1 binary bit is enough.
An admirable reason. On more than one occasion I have commented a bool in C51 as "true or false or maybe"
It would have been better for you to say at the first that you'd prefer bool and bit to be precisely one bit rather than wanting them both to be the same (unspecified) size. That would have removed any doubt in what you meant.