CSCE 315 Read-Only Bulletin Board

Last modified: 9/3/15, 12:16PM (Thu)

Newest transactions will be posted on the top. Regularly view this page to see what's going on between other students and the instructor.

All sensitive material such as your name, email address, etc. will be removed, and also any part of code that is not relevant to the discussion will not be uploaded here.


Article List

Date: 09/02 Title: Neat Compiler Trick


Articles

Date: 09/02 Title: Neat Compiler Trick

Here's a small trick to make it easier to define tokens and their corresponding
strings. See Steve Oualline, Practical C++ Programming, O'Reilly and Associates, Inc., 1995. pp460-461.

//----------------------------------------------------------------------------
//  Using the define trick to generate tokens and their strings
//----------------------------------------------------------------------------

#define _TOK T(_tik),T(_tak),T(_tok),T(_toe)

#define T(X) X
enum TOKTYPE { _TOK };

#undef T
#define T(X) #X
char TOKSTR[4][20]={ _TOK };


// The above is equivalent to

enum TOKTYPE { _tik, _tak, _tok, _toe };

char TOKSTR[4][20]={"_tik", "_tak", "_tok", "_toe" };


$Id: board.php,v 1.5 2004/08/30 23:54:24 choe Exp $