The smallest C ++ program to compile

What is the smallest C ++ program that will compile without errors?

Functionality is not important.

+7
source share
4 answers

I believe that it is he

int main(){} 
+5
source

The following should be the shortest:

 int main(){} 

Note that throwing a return value without invoking undefined behavior is only possible with main() .

+9
source

This will be a compilation, but not a link .;)

 ~/blargh 16:48:24 $ cat t.cpp ~/blargh 16:50:21 $ clang++ -c t.cpp ~/blargh 16:50:28 $ 
+6
source
 int main; 

compile with gcc without warning.

+2
source

All Articles