Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Is the C Preprocessor Turing complete?

Name: Anonymous 2009-07-07 2:16

Is the C preprocessor turing complete? Of course there are no #while loops or anything, but consider this:

"hax.h":
#if VALUE < 1
#define VALUE 1
#else
#include "hax.h"
#endif


Here, hax.h include itself, creating a loop. There isn't a way to pass a value to the included file, though.

Name: Anonymous 2009-07-07 6:01

There isn't a way to pass a value to the included file, though.
There sort of is, by defining the value and then including the file you want it to be passed to.

/* hax.h */
#ifndef VALUE
# define VALUE 1
#else
# define VALUE VALUE + 1
# if VALUE < 6
#  include "hax.h"
# endif
#endif

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List