0

When I compile the C code, but I got #include nested too deeply error.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {

  if (argc == 1) {
      printf("Usage: %s NUM\n", argv[0]);
      return 1;
  }

  int n = strtol(argv[1], NULL, 10);

  for (int i = 0; i < n; i++) {
      printf("%d", i);
  }
  return 0;
}

That's the whole completed program I got, I am running this program in MacOS, but I do not know why it's happening, since I only got two #include here.

LY Wang
  • 13
  • 1
  • 2
  • 1
    what does the error say? I've never seen an error that says "`#include` nested too deeply" – yano Mar 16 '18 at 01:58
  • Are you sure this is your whole file? You're not `#include`ing any other headers that you've authored? – Joe Mar 16 '18 at 02:04
  • @yano clang reports this error, from what i've seen. perhaps others. many times because of missing or incorrect `#include` guards but generally in user-written header files and not system ones... – Joe Mar 16 '18 at 02:07
  • @Joe interesting.. Ive hardly used clang so that makes sense – yano Mar 16 '18 at 02:09
  • 1
    I can't repeat this with clang/LLVM 9.0 on MacOS high sierra... The code above compiles and generates the expected output. – Joe Mar 16 '18 at 02:09
  • 2
    https://ideone.com/cDMUl3, it compiles fine on ideone - you'll need to give more info (compiler and OS versions) and even then the issue is unlikely to be solvable here because it isn't a program error (the program compiles fine). – dave Mar 16 '18 at 02:12
  • 1
    Please show your compiling command. There are only two #include in your program, but if you are using gcc, `-include` option will automatically added specific header filer to your program. – gzh Mar 16 '18 at 05:54

0 Answers0