If I have a c project where my main program needs file1 and file2 but file2 also needs file1. Is there a way I can get around including file2 in both main and file1? If I have an include guard, will this prevent file1.c from being added twice?

```
//file1.h
#ifndef FILE1_H
#define FILE1_H

void func1(void);
#endif

```

--

```
//file1.c
#include "file1.h"
void func1(void) {
  ..do something
}

```

--

```
//file2.h
#ifndef FILE2_H
#define FILE2_H

void func2(void);
#endif

```

--

```
//file2.c
#include "file2.h"
#include "file1.h"

void func2(void) {
  ..do something
  func1();
}

```

--

```
//main.c
#include "file1.h"
#include "file2.h"

int main(void) {
  func1();
  func2();

  return 0;
}

```

-- Since file2 includes file1, can I do this? will it prevent repetition of file1 code?

```
//main.c (alternate)
#include "file2.h"

int main(void) {
  func1();
  func2();

  return 0;
}

```

I'm not too concerned about problems arising if file2 decides to no longer include file1 in the future. I'm much more concerned with wasted space.

What I'd like to know is A: does the include guard prevent the code duplication and if so, there is no additional space used by including file1 in both main.c and file2.c. B: in the case that extra space is being used, will my alternate main.c work?