Board index » cppbuilder » Expression syntax

Expression syntax


2005-02-19 10:45:39 AM
cppbuilder35
Can someone help me. I get an "Expression syntax" error when I try this
code, why? Is there a better way?
#define cBITN_LPTP_POWER 0
#define cBITN_LPTP_RSCL 5
#define cBITN_LPTP_RSDA 4
#define cBITN_LPTP_POWER 0
#define cBITN_LPTP_WSCL 2
#define cBITN_LPTP_WSDA 1
typedef unsigned char tUBYTE;
tUBYTE cFI2C_LPT_MAPPING;
cFI2C_LPT_MAPPING[]={
cBITN_LPTP_POWER, 1,
cBITN_LPTP_RSCL , 1,
cBITN_LPTP_RSDA , 1,
cBITN_LPTP_POWER, 1,
cBITN_LPTP_WSCL , 0,
cBITN_LPTP_WSDA , 0
};
 
 

Re:Expression syntax

"Maurice Anderson" < XXXX@XXXXX.COM >wrote in message
Quote
tUBYTE cFI2C_LPT_MAPPING;

cFI2C_LPT_MAPPING[]={
cBITN_LPTP_POWER, 1,
cBITN_LPTP_RSCL , 1,
cBITN_LPTP_RSDA , 1,
cBITN_LPTP_POWER, 1,
cBITN_LPTP_WSCL , 0,
cBITN_LPTP_WSDA , 0
};
That is not a valid array declaration. You separated the array name from
the rest of its declaration. They need to be combined into a single
statement like the following:
tUBYTE cFI2C_LPT_MAPPING[] = {
cBITN_LPTP_POWER, 1,
cBITN_LPTP_RSCL , 1,
cBITN_LPTP_RSDA , 1,
cBITN_LPTP_POWER, 1,
cBITN_LPTP_WSCL , 0,
cBITN_LPTP_WSDA , 0
};
Gambit
 

Re:Expression syntax

They need to be combined into a single
Quote
statement like the following:

tUBYTE cFI2C_LPT_MAPPING[] = {
cBITN_LPTP_POWER, 1,
cBITN_LPTP_RSCL , 1,
cBITN_LPTP_RSDA , 1,
cBITN_LPTP_POWER, 1,
cBITN_LPTP_WSCL , 0,
cBITN_LPTP_WSDA , 0
};
Thanks for your response, I tried the above but my compiler says "Can't
intialize class member here".
 

{smallsort}

Re:Expression syntax

"Maurice Anderson" < XXXX@XXXXX.COM >wrote in message
Quote
Thanks for your response, I tried the above but my compiler
says "Can't intialize class member here".
Are you, by chance, declaring the array inside of a class? You did not show
that earlier. If you are, then the compiler is correct - you cannot
initialize class members inside the class declaration. You will have to
initialize the array elsewhere, such as in the class's constructor:
class TSomeClass
{
tUBYTE cFI2C_LPT_MAPPING[12];
TSomeClass();
};
TSomeClass::TSomeClass()
{
cFI2C_LPT_MAPPING[0] = cBITN_LPTP_POWER;
cFI2C_LPT_MAPPING[1] = 1;
cFI2C_LPT_MAPPING[2] = cBITN_LPTP_RSCL;
cFI2C_LPT_MAPPING[3] = 1;
cFI2C_LPT_MAPPING[4] = cBITN_LPTP_RSDA;
cFI2C_LPT_MAPPING[5] = 1;
cFI2C_LPT_MAPPING[6] = cBITN_LPTP_POWER;
cFI2C_LPT_MAPPING[7] = 1;
cFI2C_LPT_MAPPING[8] = cBITN_LPTP_WSCL;
cFI2C_LPT_MAPPING[9] = 0;
cFI2C_LPT_MAPPING[10] = cBITN_LPTP_WSDA;
cFI2C_LPT_MAPPING[11] = 0;
}
Gambit