I want to remove all comments in a `toy.c` file. From [Remove comments from C/C++ code](https://stackoverflow.com/q/2394017/4891738) I see that I could use

```
gcc -E -fpreprocessed -P -dD toy.c

```

But some of my code (say deprecated functions that I don't want to compile) are wrapped up [between `#if 0` and `endif`, as if they were commented out](https://stackoverflow.com/q/3630601/4891738).

* One one hand, the above command does not remove this type of "comment" because its removal is only possible during macro expansion, which `-fpreprocessed` prevents;
* On the other hand, I have other macros I don't want to expand, so dropping `-fpreprocessed` is a bad idea.

I see a dilemma here. Is there a way out of this situation? Thanks.

---

The following toy example "toy.c" is sufficient to illustrate the problem.

```
#define foo 3  /* this is a macro */

// a toy function
int main (void) {
  return foo;
  }

// this is deprecated
#if 0
int main (void) {
  printf("%d\n", foo);
  return 0;
  }
#endif

```

`gcc -E -fpreprocessed -P -dD toy.c` gives

```
#define foo 3
int main (void) {
  return foo;
  }
#if 0
int main (void) {
  printf("%d\n", foo);
  return 0;
  }
#endif

```

while `gcc -E -P toy.c` gives

```
int main (void) {
  return 3;
  }

```