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-10 18:29

The specification for the C preprocessor isn't Touring Complete, but I wouldn't be surprised if any of the implementations were. Technical specifications aside, it seems quite reasonable to fully emulate a RMP using the C preprocessor. Assuming every file in the program represented a node in the RMP. We can in any file: increment a counter (variable) by one and jump to any other node including the current one (by including it), check if a variable is zero, and if so jump to another node, or decrease a variable and jump to another node.

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