-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacro.c
More file actions
28 lines (25 loc) · 1.13 KB
/
macro.c
File metadata and controls
28 lines (25 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
/* Compile Processing
* 1. Preprocessor
* 2. Compilation
* 3. Assembling
* 4. Linking
*
*/
#define MAX_IDs 32 //4 Bytes (4*8)
#define PRINT_VAR(x) printf("%s = %d\n", #x, x)
/* "we can control how these function behaves through these constant variables at compile time".
* defining a PRINT_VAR as new print function which takes,
* x value as argument and print in mentioned way.
* NOTE: : A common approach is to create a macro that takes the variable and uses the preprocessor's stringification operator (#). The stringification operator, #, converts its macro argument into a string literal.
* #define MACRO | for more check : https://g.co/gemini/share/b859bd99cddc
* */
int main(){
int A_ids[MAX_IDs] = {0, 1, 2, 3}; // array of size 4 Bytes or 32 bit
int B_ids[] = {0, 1, 2, 3}; // definatioh with the exact array elemnts, no need to assign size
A_ids[3] = 0x41; // array of size 3 bit (0 0 0 to 1 1 1) with the of hexdec which is 0 to 5 in range
// but you can't do -> int C_ids[3] = 0x41; // wrong assumption X
//A_ids[3] means array A_idsand its 3rd index position.
PRINT_VAR(A_ids[3]);
return 0;
}