Connecting Tech Pros Worldwide Help | Site Map

Can This C Code Compile Under g++

  #1  
Old August 19th, 2005, 03:55 AM
Jack
Guest
 
Posts: n/a
The code at the bottom is obfuscated c and was a category winner of the
1989 IOCCC
http://www.ioccc.org/1989/roemer.c
Does anyone have a trick to make it compile under g++? Thanks.


char
_3141592654[3141
],__3141[3141];_314159[31415],_3141[31415];main(){register char*
_3_141,*_3_1415, *_3__1415; register int
_314,_31415,__31415,*_31,
_3_14159,__3_1415;*_3141592654=__31415=2,_31415926 54[0][_3141592654
-1]=1[__3141]=5;__3_1415=1;do{_3_14159=_314=0,__31415++;for( _31415
=0;_31415<(3,14-4)*__31415;_31415++)_31415[_3141]=_314159[_31415]= -
1;_3141[*_314159=_3_14159]=_314;_3_141=_3141592654+__3_1415;_3_1415=
__3_1415 +__3141;for (_31415 = 3141-
__3_1415 ; _31415;_31415--
,_3_141 ++, _3_1415++){_314
+=_314<<2 ; _314<<=1;_314+=
*_3_1415;_31 =_314159+_314;
if(!(*_31+1) )* _31 =_314 /
__31415,_314 [_3141]=_314 %
__31415 ;* ( _3__1415=_3_141
)+= *_3_1415 = *_31;while(*
_3__1415 >= 31415/3141 ) *
_3__1415+= - 10,(*--_3__1415
)++;_314=_314 [_3141]; if ( !
_3_14159 && * _3_1415)_3_14159
=1,__3_1415 = 3141-_31415;}if(
_314+(__31415 >>1)>=__31415 )
while ( ++ * _3_141==3141/314
)*_3_141--=0 ;}while(_3_14159
) ; { char * __3_14= "3.1415";
write((3,1), (--*__3_14,__3_14
),(_3_14159 ++,++_3_14159))+
3.1415926; } for ( _31415 = 1;
_31415<3141- 1;_31415++)write(
31415% 314-( 3,14),_3141592654[
_31415 ] + "0123456789","314"
[ 3]+1)-_314; puts((*_3141592654=0
,_3141592654)) ;_314= *"3.141592";}

  #2  
Old August 19th, 2005, 05:15 AM
Victor Bazarov
Guest
 
Posts: n/a

re: Can This C Code Compile Under g++


Jack wrote:[color=blue]
> The code at the bottom is obfuscated c and was a category winner of
> the 1989 IOCCC
> http://www.ioccc.org/1989/roemer.c
> Does anyone have a trick to make it compile under g++? Thanks.
>
>
> ...[/color]

No, the code won't compile under current compilers. Too much non-
standard stuff in it.

V


  #3  
Old August 19th, 2005, 06:35 AM
Greg
Guest
 
Posts: n/a

re: Can This C Code Compile Under g++


Victor Bazarov wrote:[color=blue]
> Jack wrote:[color=green]
> > The code at the bottom is obfuscated c and was a category winner of
> > the 1989 IOCCC
> > http://www.ioccc.org/1989/roemer.c
> > Does anyone have a trick to make it compile under g++? Thanks.
> >
> >
> > ...[/color]
>
> No, the code won't compile under current compilers. Too much non-
> standard stuff in it.
>
> V[/color]

gcc 4.0 will compile this source once the three or so stray space
characters that are splitting integer constants into two tokens are
removed. These spaces were were apparently inserted by the posting
software and are not part of the original C program.

Note that this is a C (not C++) program and should be saved to a file
with ".c" extension. The gcc compiler when compiling this code does
issue a few warnings about implicit int declarations, but these
warnings are not errors in C, apparently. Also I cannot get the built
program to run without crashing, so I may look further into the problem
there. These obfuscated C programs, though often difficult to tell what
they are doing from their source code (no kidding), were supposed to do
something useful when they did run.

Greg

  #4  
Old August 19th, 2005, 06:35 AM
Nikos Chantziaras
Guest
 
Posts: n/a

re: Can This C Code Compile Under g++


Jack wrote:[color=blue]
> The code at the bottom is obfuscated c and was a category winner of the
> 1989 IOCCC
> http://www.ioccc.org/1989/roemer.c
> Does anyone have a trick to make it compile under g++? Thanks.[/color]

g++? It's a C program. It compiles just fine in gcc (v3.4.4). It
doesn't run (segfault), but compiles. Is there a reason why you need to
compile it as C++ instead of C?
  #5  
Old August 19th, 2005, 05:45 PM
Jerry Coffin
Guest
 
Posts: n/a

re: Can This C Code Compile Under g++


Greg wrote:

[ ... ]
[color=blue]
> These obfuscated C programs, though often difficult to tell what
> they are doing from their source code (no kidding), were supposed to do
> something useful when they did run.[/color]

In this case "useful" would be stretching it a bit -- all it does is
compute e (the base of natural logarithms) to some inordinate level of
precision.

--
Later,
Jerry.

The universe is a figment of its own imagination.

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is the error in this code? Erwin Lindemann answers 5 January 23rd, 2008 08:35 PM
Why does this code work? Daniel Billingsley answers 18 November 16th, 2005 09:06 AM
Advice on this code LenS answers 1 October 13th, 2005 12:25 AM
va_start and template functions do not compile under gcc 2.7.2 frankg answers 4 July 19th, 2005 04:49 PM