Really it's not just hardware it's anywhere you want to guarantee the code does not get optimized away. It isn't just hardware it can be extern's (which you misunderstand below) that confuses the optimizer and you need to be able to correct. It actually isn't a compiler instruction at all its an optimizer instruction that is passed thru the compile phase.DavidS wrote:volitile Used often, and needed when dealing with HW that can be changed by an external source.
Subtracting unsigned (1) from unsigned (0) gives you max unsigned type that is what the C standard says. Not on every C implementation and processor does max unsigned happen to equal negative 1. Most yes but it isn't a guarantee it just happens most processors at this point in time are twos complement. The same people you will find have no concept of what size_t is and it's use and importance.DavidS wrote:volitile signed When working in systems that default to a unsigned char type for byte size data you are going to need to specify when you are using signed bytes.
You can not ignore it anyone who wants to link assembler or external libraries to C has to have it. Again it's misunderstood by novices because it really isn't a compiler instruction it is a linker instruction that is passed thru the compiler. Anyone working on an embedded system pretty much has to have it as you can't link an assembler module to a c prototype without it. Nor can you link an external library to C without it.DavidS wrote:extern As it is implicit in all cases where needed yes it can be ignored.
Again totally misunderstood by novices because it is a linker instruction used to define a read only entry. On systems with ROM it tells the linker to put the entry in the ROM area of memory. To not have the instruction means you would have to build the ROM block as a self stand module a complete nightmare. Telling the compiler something is read only might not be that interesting to you but the linker sure as hell wants to know if it has ROM.DavidS wrote:extern const Arguable, though I agree that it can be ignored.
My one thing I would add as mandatory teaching for C and C++ programming is there is a standard unit called <stdint.h> please use it rather than define your own types. The only exception to using the standard is when programming for an API where the API will dictate the types. It makes me want to kill people when I find u8, u16,u32 and the like .. what a waste of time and effort.