Language C/C++ Preprocessor
Date: | 04/20/05 |
Author: | Wim Rijnders |
URL: | n/a |
Comments: | 7 |
Info: | n/a |
Score: | ![]() |
This is the pre-processor for C or C++. Normally, not a language in itself, but created to make using C/C++ easier. This is a novel use of the pre-processor -- BEER.CPP --------------------------------------------------------- // 99 Bottles written entirely in Visual C++ preprocessor directives. // By Wim Rijnders. #pragma warning(disable : 4005 ) #define BOTTLES "bottles" #define TAKE_ONE_DOWN "Take one down, pass it around," #define DEC_NUM 9 #define DEC_STR "9" #define DEC2_NUM 9 #define DEC2_STR "9" #define TEST_BOTTLES(a,b) (DEC2_NUM == a && DEC_NUM == b ) #define STILL_HAVE__BOTTLES !TEST_BOTTLES(0,0) #define NO_MORE__BOTTLES TEST_BOTTLES(0,0) #define JUST_ONE__BOTTLE TEST_BOTTLES(0,1) #define OF_BEER DEC2_STR DEC_STR " " BOTTLES " of beer" #define BEER_ON_WALL OF_BEER " on the wall" #include "sing.h" -- SING.H ----------------------------------------------------------- //Following to beat the 32-file include limit of VC #if STILL_HAVE__BOTTLES #include "stanza.h" #include "stanza.h" #include "stanza.h" #include "stanza.h" #include "sing.h" #endif -- STANZA.H --------------------------------------------------------- #if STILL_HAVE__BOTTLES #pragma message(BEER_ON_WALL ",") #pragma message(OF_BEER ",") #pragma message(TAKE_ONE_DOWN) #include "dec.h" #if NO_MORE__BOTTLES #define DEC2_STR "" #define DEC_STR "No more" #endif #if JUST_ONE__BOTTLE #define BOTTLES "bottle" #else #define BOTTLES "bottles" #endif #pragma message(BEER_ON_WALL ".") #pragma message("") #endif -- DEC.H ------------------------------------------------------------ #if DEC_NUM == 9 #define DEC_NUM 8 #define DEC_STR "8" #elif DEC_NUM == 8 #define DEC_NUM 7 #define DEC_STR "7" #elif DEC_NUM == 7 #define DEC_NUM 6 #define DEC_STR "6" #elif DEC_NUM == 6 #define DEC_NUM 5 #define DEC_STR "5" #elif DEC_NUM == 5 #define DEC_NUM 4 #define DEC_STR "4" #elif DEC_NUM == 4 #define DEC_NUM 3 #define DEC_STR "3" #elif DEC_NUM == 3 #define DEC_NUM 2 #define DEC_STR "2" #elif DEC_NUM == 2 #define DEC_NUM 1 #define DEC_STR "1" #elif DEC_NUM == 1 #define DEC_NUM 0 #define DEC_STR "0" #elif DEC_NUM == 0 #include "dec2.h" #define DEC_NUM 9 #define DEC_STR "9" #endif -- DEC2.H ----------------------------------------------------------- #if DEC2_NUM == 9 #define DEC2_NUM 8 #define DEC2_STR "8" #elif DEC2_NUM == 8 #define DEC2_NUM 7 #define DEC2_STR "7" #elif DEC2_NUM == 7 #define DEC2_NUM 6 #define DEC2_STR "6" #elif DEC2_NUM == 6 #define DEC2_NUM 5 #define DEC2_STR "5" #elif DEC2_NUM == 5 #define DEC2_NUM 4 #define DEC2_STR "4" #elif DEC2_NUM == 4 #define DEC2_NUM 3 #define DEC2_STR "3" #elif DEC2_NUM == 3 #define DEC2_NUM 2 #define DEC2_STR "2" #elif DEC2_NUM == 2 #define DEC2_NUM 1 #define DEC2_STR "1" #elif DEC2_NUM == 1 #define DEC2_NUM 0 #define DEC2_STR "" #endif
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
Direct output (general / GNU) | Gerry JJ | 12/30/05 | 2 | ![]() ![]() |
with Order interpreter | Vesa Karvonen | 12/30/05 | 1 | ![]() ![]() |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
I like it.
http://www.totalscreenrecorder.com
GodswMobile Software dedicated to providing a better experience life for the people who use and rely upon Microsoft Windows Mobile devices for their personal and commercial needs. With thousands of users over 50 countries worldwide, GodswMobile has become the popular, trusted and convenient choice to backup and restore the valuable information which stored in mobile phones.
http://www.godswmobile.com/