Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 19th, 2005, 03:55 AM
Jack
Guest
 
Posts: n/a
Default Can This C Code Compile Under g++

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
Default 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
Default 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
Default 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
Default 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.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles