title: How do I compile a file whose name begins with “-” (hyphen a.k.a. dash or minus)?
body: <p>I have a file called <code>-.o</code> that was created with:</p>
  
  <pre><code>echo "int main(){}" | cc -xc -c -
  </code></pre>
  
  <p><strong>How do I link this file to a binary ?</strong></p>
  
  <p>The command is the same as :</p>
  
  <pre><code>echo "int main(){}" | cc -xc -c - -o-.o
  </code></pre>
  
  <p>Where <code>cc</code> is the default compiler (tested with <code>gcc 4.8.4</code> and <code>clang 800.0.42.1</code>), <code>-xc</code> considers input to be written in C language, <code>-c</code> generates object file, <code>-</code> takes stdin as input file and <code>-o-.o</code> specifies the name of the output file.</p>
  
  <p>All of these commands fail :</p>
  
  <pre><code>cc -.o
  cc -- -.o
  cc "-.o"
  cc \-.o
  cc \\-.o
  cc "\-.o"
  </code></pre>
  
  <p>With errors like this :</p>
  
  <pre><code>cc: error: unrecognized command line option ‘--’
  cc: error: unrecognized command line option ‘-.o’
  cc: error: \-.o: No such file or directory
  </code></pre>
  
  <p>Obviously I could rename the file but this is not the point here. I wonder why the <code>--</code> is not implemented as in ls, cp, mv, ...</p>