Thursday, December 25, 2025

C program compilation steps

 Preprocessor:

> gcc -E main.c -o main.i

Compilation:

> gcc -S main.i -o main.s

Assembler: Convert .S to obj file

>gcc -c main.s  -o main.o

>objdump -h main.o  // -> to view the .o file 

Linking:

gcc main.o -o main


> nm main.o // -> to view all the sections 

Saturday, December 20, 2025

Explain with example "const int *const ptr" and its use

 This is for readonly purpose

const int *const ptr _> read as constant pointer to integer constant.

const int -> variable value must not be modified

*const ptr -> ptr should point to the same address.

This prevents

1) Accidental modification of the value

2) Accidental modification of the address.