Doglao 0 Posted November 15, 2007 Report Share Posted November 15, 2007 Hi! I make a attempt to put a structure in a class and then shows this error message "missing right brace". are not accepted structures as member of class? thanks! class Cmcp23016{ public: Cmcp23016(); Cmcp23016(int); ~Cmcp23016(); void WriteMcp23016(int iSlaveAddr, int iCommandByte, int iLsb, int iMsb); void LeMcp23016(int iSlaveAddr, int iCommandByte); void config_mcp(int slave); private: int m_iVarGp0;//varialvel do byte baixo do mcp23016 int m_iVarGp1;//varialvel do byte alto do mcp23016 struct DoisBytes{// the message error highlighting this line unsigned char iLsb; unsigned char iMsb; }; union Converse { int Gp; struct DoisBytes Gp0e1; }Totaliza; }; Quote Link to post Share on other sites
Pavel 0 Posted November 15, 2007 Report Share Posted November 15, 2007 class Cmcp23016{ ... struct DoisBytes{ unsigned char iLsb; unsigned char iMsb; } v; // <--- you need to have a variable name here !!! ... }; Regards, Pavel Quote Link to post Share on other sites
Doglao 0 Posted November 20, 2007 Author Report Share Posted November 20, 2007 class Cmcp23016{ ... struct DoisBytes{ unsigned char iLsb; unsigned char iMsb; } v; // <--- you need to have a variable name here !!! ... }; Regards, Pavel thank you a lot Mr. Pavel, this works fine now, but I have to put the struct on inside the union to take the effect that I hope, is this a BoostC++ limitation or a normal behavior of C++ ? #include <i2c_driver.h> /* * * * * * * * * * * * * * * * * * * * * * * i2c hardwareware argumentos da template * * * * * * * * * * * * * * * * * * * * * */ #define i2c_ARGS 3, e_PORT, e_TRIS, 4, e_PORT, e_TRIS, \ e_SSPCON, e_SSPCON2, e_SSPSTAT, e_SSPBUF, \ e_SSPIF, e_PIR2, e_BCLIF, e_PIR2, 7, e_SSPADD,\ (i2c_reset_wdt | i2c_SMP |i2c_HW) // variaveis nano pondem ser passadas como argumentos de template. As seguintes constantes mapea // os registros do PIC e os registros i2c do PIC. Estas constantes sao entao usadas pela funcao template. #define e_PORT PORTC #define e_TRIS TRISC #define e_SSPCON SSPCON #define e_SSPCON2 SSPCON2 #define e_SSPSTAT SSPSTAT #define e_SSPADD SSPADD #define e_SSPBUF SSPBUF #define e_PIR1 PIR1 #define e_PIR2 PIR2 #define e_SSPIF SSPIF #define e_BCLIF BCLIF //////////////////////////////////////////////////////////////////////////// // I2C MCP23016 expander de portas I/O //////////////////////////////////////////////////////////////////////////// #define gp0 0x00 //Porta GP0 #define olat0 0x02 // #define ipol0 0x04 //registrador de polaridade de entrada do GP0 #define iodir0 0x06 //registrador que define como entrada ou saida GP0 #define intcap0 0x08 //registrador de captura de interrupcao do GP0 #define iocon0 0x0a //registrador para velocidade de amostragem de interrupcao AIRES0 //definicoes dos enderecos dos escravos com os comandos de leitura ou escita #define slave_1 0b01000000//endereco do escravo 1 comando de escrita + 1 leitura #define slave_2 0b01000010//endereco do escravo 2 comando de escrita + 1 leitura #define slave_3 0b01000100//endereco do escravo 3 comando de escrita + 1 leitura #define slave_4 0b01000110//endereco do escravo 4 comando de escrita + 1 leitura #define slave_5 0b01001000//endereco do escravo 5 comando de escrita + 1 leitura #define slave_6 0b01001010//endereco do escravo 6 comando de escrita + 1 leitura #define slave_7 0b01001100//endereco do escravo 7 comando de escrita + 1 leitura #define slave_8 0b01001110//endereco do escravo 8 comando de escrita + 1 leitura class Cmcp23016{ public: Cmcp23016();//construtor Cmcp23016(unsigned char);//inicialzar os mcp23016 passados por parametros no de 1 a 8 dispositivos ~Cmcp23016(); void Write_MCP23016(unsigned char SlaveAddr, unsigned char CommandByte, unsigned char Lsb, unsigned char Msb); void Read_MCP23016(unsigned char SlaveAddr, unsigned char CommandByte); void config_mcp(unsigned char slave); void esc_dados(unsigned char, unsigned char); private: unsigned char m_ucVarGp0;//varialvel do byte baixo do mcp23016 unsigned char m_ucVarGp1;//varialvel do byte alto do mcp23016 union Converse { int Gp; struct DoisBytes{ unsigned char ucLsb; unsigned char ucMsb; }Gp0e1; }Totaliza; }; Thanks! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.