![]() |
| | #1 |
| Registered User Join Date: Apr 2009
Posts: 53
| Problem with macros.. Using microcontrollers Code: #define MALLOC(size) pvBosMemAlloc( size )
#define FREE ( a ) bBosMemFree ( a )
typedef struct {
uint8 i;
char ch[6];
}mine;
uint8 zcl_SendCommand(mine *pMsg)
{
mine *rcv;
rcv = MALLOC(sizeof(mine));
//Some code
FREE (rcv);
}
Source\zcl.c:267: error: 'a' undeclared (first use in this function) Source\zcl.c:267: error: (Each undeclared identifier is reported only once Source\zcl.c:267: error: for each function it appears in.) Source\zcl.c:267: error: expected ';' before 'bBosMemFree' What may be wrong with the code..... Thanks |
| sanddune008 is offline | |
| | #2 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Try changing this: Code: #define FREE ( a ) bBosMemFree ( a ) Code: #define FREE(a) bBosMemFree( a )
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #3 | |
| Registered User Join Date: Apr 2009
Posts: 53
| Thanks for your time...... Quote:
Anyways i tried didn't compile had same error.... Why does the error states: error: 'a' undeclared (first use in this function) | |
| sanddune008 is offline | |
| | #4 | ||
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Quote:
Quote:
Code: #include <stddef.h>
void *pvBosMemAlloc(size_t size)
{
return NULL;
}
void *bBosMemFree(void *p)
{
return p;
}
#define MALLOC(size) pvBosMemAlloc( size )
#define FREE(a) bBosMemFree( a )
typedef unsigned char uint8;
typedef struct {
uint8 i;
char ch[6];
} mine;
uint8 zcl_SendCommand(mine *pMsg)
{
mine *rcv;
rcv = MALLOC(sizeof(mine));
/*Some code*/
FREE(rcv);
return 0;
}
int main(void)
{
return 0;
}
Code: #define FREE(a) bBosMemFree( a ) Code: #define FREE (a) bBosMemFree( a )
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way | ||
| laserlight is offline | |
| | #5 |
| Registered User Join Date: Apr 2009
Posts: 53
| Thanks for your time..... You were right there shouldn't space b/w FREE(a) |
| sanddune008 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help understanding a problem | dnguyen1022 | C++ Programming | 2 | 04-29-2009 04:21 PM |
| Memory problem with Borland C 3.1 | AZ1699 | C Programming | 16 | 11-16-2007 11:22 AM |
| Someone having same problem with Code Block? | ofayto | C++ Programming | 1 | 07-12-2007 08:38 AM |
| A question related to strcmp | meili100 | C++ Programming | 6 | 07-07-2007 02:51 PM |
| WS_POPUP, continuation of old problem | blurrymadness | Windows Programming | 1 | 04-20-2007 06:54 PM |