#pragma is a compiler directive that directs the compiler to perform actions in specified ways. Pragmas can affect the behaviour of the compiler

#pragma comment(lib, libname)

This adds libname to the list of library dependencies as if you have manually added it

There’s another important use of #pragma, especially #pragma once. It functions like an include guard, ensuring that the program file it’s in gets compiled only once. This is important in files where the header file it resides in is mentioned in multiple program files/header files. Moreover, almost all the major and popular C/C++ compilers except for SDCC accept its usage.

No need to compile header files

I was being a rock and I did gcc program.c header.h -o test where #pragma once was in header.h. Naturally, I got a warning warning: #pragma once in main file. This warning is harmless and the solution is to not pass header files to gcc

The name “pragma” comes from the word “pragmatic” and was used far back in ALGOL 68 as pragmats, which were compiler directives. Think of it as telling the compiler to act pragmatically