Search code examples
cshebangmagic-numbers

Does a C source-code/script/program uses a shebang-like command?


might be a stupid question but I'll try anyway:

when you turn a shell-script into an executable, it uses the shebang to knows which interpreter to use when you run it. Does a C code/script/program uses/has something similar?

are there any magic numbers in the beginning of an executable C-program?


Solution

  • Yes.

    C program executables (and all compiled languages) start with the "magic" characters 0x7f E L F. The Linux kernel recognises this in the same way as it recognises shebang scripts, except that it then triggers the ELF loader, not the script interpreter.

    It's not actually shebang, but it's analogous.