[Question]
  [
## The challenge:
Write a very short program that, when compiled, creates the most amount of compiler warnings and errors. It can be written in any programming language.
## Scoring:
The score is determined by this equation: `errors_and_warnings_length/code_length`. Highest score wins.
## Example:
The C# program `class` is 5 chars long and generates 3 warnings, which is a score of (1/5)\*3 = 0.6.
## EDIT:
Because of some confusion, programs have to be at least 1 char long. Otherwise it would get a score of infinity.
  
[Answer]
## GCC, score 2200 / 36 ≈ 4.5 × 1058
```
#include __FILE__
#include __FILE__
```
I have not actually finished compiling this code, but based on testing and simple mathematics, it should produce a total of 2200 `#include nested too deeply` errors.
Of course, the program is trivially extensible. Adding a third line brings the score up to **3200 / 54 ≈ 4.9 × 1093**. Four lines give **4200 / 72 ≈ 3.6 × 10118**, and so on.
[Answer]
## C, 0 characters - Score=(1/0)\*1=Infinity
generates 1 error:
```
/usr/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
```
Note: <http://ideone.com/xdoJyA>
[Answer]
## GCC, score 5586.6 (and more if needed)
179 chars, 1000003 warnings/errors (using `-Wall`)
```
#define E a,a,a,a,a,a,a,a,a,a
#define D E,E,E,E,E,E,E,E,E,E
#define C D,D,D,D,D,D,D,D,D,D
#define B C,C,C,C,C,C,C,C,C,C
#define A B,B,B,B,B,B,B,B,B,B
_(){A,A,A,A,A,A,A,A,A,A}
```
This can be extended arbitrarily, of course. For example, using 10 `#define`s instead of 5 and a length of 20 "calls" instead of 10 would lead to a score of about (20\*\*10)/(179\*4) = 14301675977.65 (and would take quite some time to run ;)
[Answer]
## GCC twice, 86
22 chars, 1898 errors+warnings on my system.  
I'm sure this approach can be much improved, by choosing longer files with shorter names.
```
#include</usr/bin/gcc>
```
[Answer]
## HQ9++, 1 (limit of (n+29)/n)
The following emits the warning `Warning: this is not a quine` for each Q in the code.
```
QQQQQ...Q
Warning: this is not a quine
```
Small is good, right? Hmm...
[Answer]
## C, .727
11 chars, 5 errors, 3 warnings, (1/11)\*8 = .727273
```
m(;){@,x}2
```
````
cc -g -Wall    er.c   -o er
er.c:1: error: expected declaration specifiers or '...' before ';' token
er.c:1: warning: return type defaults to 'int'
er.c: In function 'm':
er.c:1: error: stray '@' in program
er.c:1: error: expected expression before ',' token
er.c:1: error: 'x' undeclared (first use in this function)
er.c:1: error: (Each undeclared identifier is reported only once
er.c:1: error: for each function it appears in.)
er.c:1: warning: left-hand operand of comma expression has no effect
er.c:1: warning: control reaches end of non-void function
er.c: At top level:
er.c:1: error: expected identifier or '(' before numeric constant
````
[Answer]
## NASM, score 63/40 \* 2^32 ≈ 2.905 \* 10^19
```
%rep 1<<32
%rep 1<<32
!
%endrep
%endrep
```
Will output `c.asm:3: error: label or instruction expected at start of line` 2^64 times. Again this is easily extensible to much bigger outputs.
[Answer]
**C++98 (211 bytes)** g++-5 (Ubuntu 5.2.1-23ubuntu1~12.04) 5.2.1 0151031
I wanted to see how well I could do in C++ without using the preprocessor at all. This program produces 2,139,390,572 bytes of output, most of which is a single error message.
```
template<int i,class S,class T>struct R{typedef R<i,typename R<i-1,S,S>::D,typename R<i-1,S,S>::D>D;};template<class S,class T>struct R<0,S,T>{typedef S D;};void f(){R<27,float,R<24,int*const*,int>::D>::D&E=4;}
me@Basement:~/src/junk$ ls -l a.C
-rw-rw-r-- 1 me me 211 Apr 27 21:44 a.C
me@Basement:~/src/junk$ g++-5 a.C -fmax-errors=1 2>a.C.errors.txt
me@Basement:~/src/junk$ ls -l a.C.errors.txt 
-rw-rw-r-- 1 me me 2139390572 Apr 27 22:01 a.C.errors.txt
```
Ungolfed:
```
template <int i, class S, class T>
struct R {
    typedef R<i, typename R<i-1,S,S>::D, typename R<i-1,S,S>::D> D;
};
template <class S, class T>
struct R<0, S, T> {
    typedef S D;
};
void f() {
    R<27, float, R<24, int*const*, int>::D>::D &E = 4;
}
```
This program works by defining a recursive struct template R which holds a typedef D containing two copies of R. This results in an type name which grows exponentially, which is printed out in full in the error message. Unfortunately, g++ seems to choke while attempting to print an error message longer than (1<<31) bytes. 2,139,390,572 bytes was the closest I could get to the limit without going over. I'm curious if anyone can adjust the recursion limits and parameter types `27, float, 24, int*const*` to get closer to the limit (or find a compiler which can print an even longer error message).
Excerpts from the error message:
```
a.C: In function ‘void f()’:
a.C:1:208:  error:  invalid  initialization  of non-const reference of type
‘R<27, float, R<24, R<23, R<22, R<21, R<20, R<19, R<18, R<17, R<16, R<15,
R<14,  R<13, R<12, R<11, R<10, R<9, R<8, R<7, R<6, R<5, R<4, R<3, R<2, R<1,
int* const*, int* const*>, R<1, int* const*, int* const*> >, R<2, R<1, int*
const*,  int*  const*>,  R<1, int* const*, int* const*> > >, R<3, R<2, R<1,
int* const*, int* const*>, R<1, int* const*, int* const*> >, R<2, R<1, int*
const*,  int* const*>, R<1, int* const*, int* const*> > > >, R<4, R<3, R<2,
R<1, int* const*, int* const*>, R<1,
...
int*  const*,  int*  const*>  > > > > > > > > > > > > > > > > > > > > > > >
>::D& {aka R<27, R<26, R<25, R<24, R<23,  R<22,  R<21,  R<20,  R<19,  R<18,
R<17,  R<16,  R<15,  R<14, R<13, R<12, R<11, R<10, R<9, R<8, R<7, R<6, R<5,
R<4, R<3, R<2, R<1, float, float>, R<1, float, float> >, R<2,  R<1,  float,
float>,  R<1,  float, float> > >, R<3, R<2, R<1, float, float>, R<1, float,
float> >, R<2, R<1, float, float>, R<1, float, float> > > >, R<4, 
...
, R<1, float, float>, R<1, float, float> > >, R<3, R<2, R<1, float, float>,
R<1, float, float> >, R<2, R<1, float, float>, R<1, float, float> > > > > >
>  >  >  >  >  >  > > > > > > > > > > > > > > >&}’ from an rvalue of type
‘int’
    template<int    i,class   S,class   T>struct   R{typedef   R<i,typename
R<i-1,S,S>::D,typename  R<i-1,S,S>::D>D;};template<class  S,class  T>struct
R<0,S,T>{typedef                         S                         D;};void
f(){R<27,float,R<24,int*const*,int>::D>::D&E=4;}
                                                        ^
compilation terminated due to -fmax-errors=1.
```
2,139,390,572 bytes / 211 bytes = 10,139,291.8
[Answer]
## Rust, 206 chars, 220+2 errors, score 5090, tunable.
```
macro_rules! e {
    ($e:expr, $($es:expr),+) => {
    compile_error!(stringify!($e, $($es),+));
        e! { $(a + $es),+ }
        e! { $(b + $es),+ }
    };
}
e! {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
```
And you can actually see it finish compilation, in about 3 minutes for me:
```
error: could not compile `a` due to 1048578 previous errors
```
Like the C `#include __FILE__` example above, it is tunable, but
* if you want to go beyond 2256, you need to set `#![recursion_limit = "9999999"]`
* rustc will OOM long before you can reach that
* longer expressions mean slower execution, so the more errors you want, the slower they will be printed
What I actually wanted to do is implement the Péter's variant of the Ackermann function. But I don't quite grok macros well enough to do that with the unary encoding. Anyone help?
[Answer]
# SmileBASIC, 1/1 = 1
```
A
```
Generates the error `Syntax Error in 0:1`
]