What function does the compiler perform when it first reaches the #include statement in a C program

I came across this question while preparing for an interview:

What function does the compiler perform when it reaches #includethe C program?

I searched for it and as far as I understand (if I’m not mistaken here) it means that it includes all the macros or definitions that are defined in #include filenamethe source code at this point in the program.

Is this the correct answer? And what does the compiler do for the operator #include?

+4
source share
1 answer

#include , . .

, :

myfunc.h:

int myfunc1(int x);
int myfunc2(int x);

main.c

#include "myfunc.h"

int main()
{
    int x = myfunc(2);
    return 0;
}

, main.c , :

int myfunc1(int x);
int myfunc2(int x);

int main()
{
    int x = myfunc(2);
    return 0;
}

, , .

, ( ), , .

+7

All Articles