-1

For my C++ class, I want to compile without including default paths. This way, if I forget to include in a file that is using assert, the compiler will throw an error. Right now, my compiler automatically includes assert.h, but the course's automatic test systems compiler will throw an error, because it doesn't auto-include, which often causes confusion.

This thread shows how to list default include directories: What are the GCC default include directories?

user541
  • 1
  • 1
  • "Right now, my compiler automatically includes assert.h" - are you sure about that ? I think you may be getting confused about what the default include *paths* are - they are just directories that get searched for headers that you specify. No headers are included by default. – Paul R May 29 '18 at 13:23
  • Standard headers may (or may not) include other standard headers. You have no control over this. – Richard Critten May 29 '18 at 13:25
  • If you always include the correct headers for the things you use, even if your code might compile without them on your particular compiler, you should be fine on all compilers. There are some exceptions where different platforms don't use the same headers, but for standard things it works. – Retired Ninja May 29 '18 at 13:32
  • https://stackoverflow.com/questions/26614983/which-headers-in-the-c-standard-library-are-guaranteed-to-include-another-head?rq=1 – Retired Ninja May 29 '18 at 13:46

1 Answers1

1

I think you're mixing at least 3 concepts. There are default include paths. They don't cause any file to be included. There are forced includes. They could cause assert.h to be included, but you have to explicitly make the compiler do that.

Finally, any C++ header may indirectly include assert.h, and that's what happens to you - as far as I can tell without seeing actual code.

MSalters
  • 173,980
  • 10
  • 155
  • 350