title: Objective-C: "Hello world" COMPILED! without Foundation header. Why?
body: <p>Consider the following code:</p>
  
  <pre><code>//#import &lt;Foundation/Foundation.h&gt;
  
  int main(int argc, const char *argv[]) {
      @autoreleasepool {
          NSLog(@"Hello World!");
      }
      return 0;
  }
  </code></pre>
  
  <p>I cannot understand why it could be built and run? w/out Foundation header!</p>
  
  <p><strong>For me it is still strange that C compiler COMPILES this code w/out header i.e. w/out DECLARATIONS. It's strange that compiler matches my function somehow to already compiled code (Foundation) and succeeds. Are there some links to C standard that will explain me how compiler resolves token that recognized as a function and was never previously declared?</strong></p>
  
  <p>Please, explain!!</p>
  
  <p>UPDATE: These if not due to pre-compiled headers</p>
  
  <p>Thank you! But NO. I tested it the following way - just typed Hello World code in vi editor and saved it as main.m file. Than compiled it with clang from Terminal. And e-thing went Okay with 1 warning only:</p>
  
  <pre><code>main.m:8:9: warning: implicitly declaring library function 'NSLog' with type 'void (id, ...)' NSLog(@"Hello World!");
  ^ main.m:8:9: note: please include the header &lt;Foundation/NSObjCRuntime.h&gt; or explicitly provide a declaration for 'NSLog'
  1 warning generated.
  </code></pre>
  
  <p>UPDATE: Just attaching all the images step-by-step:
  <img src="https://i.stack.imgur.com/wUk98.png" alt="The only file in directory main.m">
  <img src="https://i.stack.imgur.com/ox9eT.png" alt="Contents of main.m - VIM">
  <img src="https://i.stack.imgur.com/eH8qj.png" alt="Compiling ... Compiled!">
  <img src="https://i.stack.imgur.com/KHhgW.png" alt="Test run of the application built"></p>