Skip to main content
2 of 5
added 3980 characters in body
nneonneo
  • 12.6k
  • 8
  • 31
  • 52

2,359.37 1,645.94 266.88 points

More preprocessor abuse! This time, we're making the standard library cry.

Without typo:

#define cha #include<fstream> 

With typo:

#define char #include<fstream> 

Errors:

In file included from /usr/include/c++/4.9/iosfwd:39:0, from /usr/include/c++/4.9/ios:38, from /usr/include/c++/4.9/istream:38, from /usr/include/c++/4.9/fstream:38, from a.C:2: /usr/include/c++/4.9/bits/stringfwd.h:59:37: error: wrong number of template arguments (0, should be 1) template<> struct char_traits<char>; ^ /usr/include/c++/4.9/bits/stringfwd.h:53:12: error: provided for ‘template<class _CharT> struct std::char_traits’ struct char_traits; ^ /usr/include/c++/4.9/bits/stringfwd.h:62:28: error: wrong number of template arguments (0, should be 3) typedef basic_string<char> string; ^ /usr/include/c++/4.9/bits/stringfwd.h:57:11: error: provided for ‘template<class _CharT, class _Traits, class _Alloc> class std::basic_string’ class basic_string; ^ /usr/include/c++/4.9/bits/stringfwd.h:62:39: error: invalid type in declaration before ‘;’ token typedef basic_string<char> string; ^ In file included from /usr/include/c++/4.9/cwchar:44:0, from /usr/include/c++/4.9/bits/postypes.h:40, from /usr/include/c++/4.9/iosfwd:40, from /usr/include/c++/4.9/ios:38, from /usr/include/c++/4.9/istream:38, from /usr/include/c++/4.9/fstream:38, from a.C:2: /usr/include/wchar.h:92:10: error: ‘__wchb’ does not name a type char __wchb[4]; ^ In file included from /usr/include/c++/4.9/cwchar:44:0, from /usr/include/c++/4.9/bits/postypes.h:40, from /usr/include/c++/4.9/iosfwd:40, from /usr/include/c++/4.9/ios:38, from /usr/include/c++/4.9/istream:38, from /usr/include/c++/4.9/fstream:38, from a.C:2: /usr/include/wchar.h:370:30: error: expected primary-expression before ‘__restrict’ extern size_t wcrtomb (char *__restrict __s, wchar_t __wc, ^ /usr/include/wchar.h:370:46: error: expected primary-expression before ‘wchar_t’ extern size_t wcrtomb (char *__restrict __s, wchar_t __wc, ^ /usr/include/wchar.h:371:20: error: expected primary-expression before ‘*’ token mbstate_t *__restrict __ps) __THROW; ^ /usr/include/wchar.h:371:21: error: expected primary-expression before ‘__restrict’ mbstate_t *__restrict __ps) __THROW; ^ /usr/include/wchar.h:371:36: error: expression list treated as compound expression in initializer [-fpermissive] mbstate_t *__restrict __ps) __THROW; ^ [SNIP...] In file included from /usr/include/c++/4.9/ios:38:0, from /usr/include/c++/4.9/istream:38, from /usr/include/c++/4.9/fstream:38, from a.C:2: /usr/include/c++/4.9/iosfwd:111:11: error: provided for ‘template<class _CharT, class _Traits> class std::basic_ifstream’ class basic_ifstream; ^ In file included from /usr/include/c++/4.9/fstream:939:0, from a.C:2: /usr/include/c++/4.9/bits/fstream.tcc:970:44: error: wrong number of template arguments (0, should be 2) extern template class basic_ofstream<char>; ^ In file included from /usr/include/c++/4.9/ios:38:0, from /usr/include/c++/4.9/istream:38, from /usr/include/c++/4.9/fstream:38, from a.C:2: /usr/include/c++/4.9/iosfwd:114:11: error: provided for ‘template<class _CharT, class _Traits> class std::basic_ofstream’ class basic_ofstream; ^ In file included from /usr/include/c++/4.9/fstream:939:0, from a.C:2: /usr/include/c++/4.9/bits/fstream.tcc:971:43: error: wrong number of template arguments (0, should be 2) extern template class basic_fstream<char>; ^ In file included from /usr/include/c++/4.9/ios:38:0, from /usr/include/c++/4.9/istream:38, from /usr/include/c++/4.9/fstream:38, from a.C:2: /usr/include/c++/4.9/iosfwd:117:11: error: provided for ‘template<class _CharT, class _Traits> class std::basic_fstream’ class basic_fstream; ^ 

On my Ubuntu machine, g++-4.9, 212,343 glorious bytes of errors with a filename of a.C. Only 30 bytes of code (with typo), for a score of 212343/30/3 = 2,359.37.

nneonneo
  • 12.6k
  • 8
  • 31
  • 52