Ali2006

Illegal constant expression. in MACRO?

Discussion created by Ali2006 on Jul 27, 2012
Latest reply on Aug 4, 2012 by CompilerGuru

Trying to use the following macro to create an offset into a structure. 

 

When I try to compile under CW10.2 I get illegal constant expression.

I have used this before with other compilers.. so we are stumped. Any ideas greatly appreciated

 

#define FIELD(type, field) {type, (((char*)&(Config. ## field)) - (char*)&Config), sizeof(Config. ##field)}

 

 

USAGE in creation of this table..

static const Command_t Cmds[] = {

// Cmd Function, {Field 1, Field 2}, ResponseCount, TestDiff,Help, Comment

{

{"DL", &cfOScope, { FIELD(dHex,Debug.Output), NO_FIELD }, 0, true, HELP("D?", "Debug LED Outputs (output num, hex event mask)" )},

{"DL?", &cfOScopeList, { NO_FIELD, NO_FIELD }, 0, false, HELP("D?", "Debug LED Output Help Listing" )},

{"DS", NULL, { FIELD(dHex,Debug.Stream), NO_FIELD }, 1, true, HELP("D?", "Debug Stream Mask (hex mask)")},

{"DSS", &cfDbgStreamSingle, { NO_FIELD, NO_FIELD, }, 0, false, HELP("D?", "Debug Stream Single Listing (hex mask)" )},

 

};

 

 

The following macro works just fine... I don't really see the difference

 

#define DoSetConfig(field, valPtr, valSize) \

SetConfig(( char*)&Config. ## field - (char*)&Config,\

(char*)(valPtr), (valSize))

Outcomes