Variable Scope:
- static variable address can be used outside its scope
- static/ variable needs to be initialised using constant
- The any local variables hide the globals
- No Two storage classes for single variable
-
- register variable can not be accessed by dereferencing pointer
The C standard specifies that enums are integers, but it does not specify the size. Once again, that is up to the people who write the compiler. On an 8-bit processor, enums can be 16-bits wide. On a 32-bit processor they can be 32-bits wide or more or less.
In normal use you really don’t have to worry about the size of your enums, they will be big enough to do what you want. But when putting them into message to be sent to another system, you should remember that they can change size and may not be what you are expecting. If you store enums in non-volatile memory or on disk, be sure to review any code that might need to be updated when the size changes.
A note on malloc() returned pointer
- The pointer returned by malloc() is void *. It can be converted to any data type as per the need of programmer. The implementer of malloc() should return a pointer that is aligned to maximum size of primitive data types (those defined by compiler). It is usually aligned to 8 byte boundary on 32 bit machines.
- Need to care ful when using generic pointer like (void *), as it is not sure that memory is aligned to required data type.
- Array members are deeply copied when a struct variable is assigned to another one.
- A structure variable can be assigned to other using =, but cannot be compared with other using ==
-In C, struct and union types cannot have static members.
-A structure cannot contain a member of its own type because if this is allowed then it becomes impossible for compiler to know size of such struct. Although a pointer of same type can be a member because pointers of all types are of same size and compiler can calculate size of struct
Bit Fields:
- How structure size is determined with bitfields: struct { int a:5, int b:2, int y};
First 4 bytes are allocated for first member bitfield a, next 2 bits of b can fit in remainting bits 4 bytes, and another 4 bytes allocated for y = 4 + 4 = 8 byets
-We cannot have pointers to bit field members as they may not start at a byte boundary
-It is implementation defined to assign an out-of-range value to a bit field member
-Array of bit fields is not allowed. For example, the below program fails in compilation.
- Array parameters are always passed as pointers, even when we use square brackets.
- void pointers cannot be dereferenced.
-The C standard doesn’t allow pointer arithmetic with void pointers. However, in GNU C it is allowed by considering the size of void is 1
######
MCARO
######
1. undefined macro are initialised to zero
2. Always try to braces around variables for macro expansion
3. macro is not expanded in the string constants
4. it can be used for fucntion names, variable type
5. v1##v2 - merged two tokens
6. macros can be nedsted.
######
MCARO
######
1. undefined macro are initialised to zero
2. Always try to braces around variables for macro expansion
3. macro is not expanded in the string constants
4. it can be used for fucntion names, variable type
5. v1##v2 - merged two tokens
6. macros can be nedsted.
Comments
Post a Comment