Hello guys!
Look please the follow code:
/*********************************************************************/
/*********************************************************************/
#define ULONG unsigned long
#define UCHAR unsigned char
#define UINT8 unsigned char
#define REG_BANK_SEL_OFFSET 0x0E
typedef struct
{
//......................
//......................
//......................
ULONG m_ulVIoAddr; /* device's base address */
ULONG m_boardBusEndianMode; /* board bus endian mode board specific */
UCHAR m_bMacOverrideAddr;
UCHAR m_bBroadcastPercent;
UCHAR m_bBank;
//......................
//......................
//......................
} HARDWARE, *PHARDWARE;
#define HW_WRITE_BYTE( phwi, addr, data ) \
*(( UINT8 *)(( phwi )->m_ulVIoAddr + addr )) = ( UINT8 )( data )
void HardwareSelectBank (PHARDWARE pHardware, UCHAR bBank )
{
HW_WRITE_BYTE( pHardware, (UCHAR)REG_BANK_SEL_OFFSET, bBank );
pHardware->m_bBank = bBank;
}
void main(void)
{
while(1)
{;}
}
/*********************************************************************/
/*********************************************************************/
After compiling, I have got compiler error "Invalid expression" and others errors too. It's "clear" C language, and I tryed compiled the same code in other compilers - no problem.
Please can you help me?
Thank you for your answer,
best regards
Compiler error
Compiler error
___________________________________________
http://www.techno-spectr.ru/en/main-en/
Yaroslavl, Russia
http://www.techno-spectr.ru/en/main-en/
Yaroslavl, Russia
Re: Compiler error
Also, the same situation with follow:
/************************************************************/
/************************************************************/
#define MAX_FILENAME 15
#define UINT32 unsigned long
#define UINT16 unsigned long
const unsigned char ml[]=
{
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d, 0x0a, 0x4c, 0x61, 0x73,
0x74, 0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64
};
struct FILE_ENTRY
{
char name[MAX_FILENAME+1];
UINT16 Size;
UINT32 sector_data[MAX_FILES_SECTORS];
UINT16 sector_data_size[MAX_FILES_SECTORS];
};
typedef struct FILE_ENTRY file_entry;
file_entry FAT[MAX_FILES+1] =
{
{ 0, 0, 0, 0},
{ "ABCDEF", tml_SIZE, {(UINT32)ml}, {tml_SIZE} }
};
void main(void)
{
while(1) {;}
}
/************************************************************/
/***************************************************************/
It's compiled by others compilers (Keil, BSO Tasking, Renesas), but by MikroC for dsPIC - no. Error - "const exp. expected"
Regards
/************************************************************/
/************************************************************/
#define MAX_FILENAME 15
#define UINT32 unsigned long
#define UINT16 unsigned long
const unsigned char ml[]=
{
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d, 0x0a, 0x4c, 0x61, 0x73,
0x74, 0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64
};
struct FILE_ENTRY
{
char name[MAX_FILENAME+1];
UINT16 Size;
UINT32 sector_data[MAX_FILES_SECTORS];
UINT16 sector_data_size[MAX_FILES_SECTORS];
};
typedef struct FILE_ENTRY file_entry;
file_entry FAT[MAX_FILES+1] =
{
{ 0, 0, 0, 0},
{ "ABCDEF", tml_SIZE, {(UINT32)ml}, {tml_SIZE} }
};
void main(void)
{
while(1) {;}
}
/************************************************************/
/***************************************************************/
It's compiled by others compilers (Keil, BSO Tasking, Renesas), but by MikroC for dsPIC - no. Error - "const exp. expected"
Regards
___________________________________________
http://www.techno-spectr.ru/en/main-en/
Yaroslavl, Russia
http://www.techno-spectr.ru/en/main-en/
Yaroslavl, Russia
Re: Compiler error
Hi,
I am sorry for such a late reply to your request.
This seems to be a case-sensitivity issue. You should go to Tools->Options->Output->Output Settings and make sure Case sensitive option is checked. Then try compiling the project again.
Best regards,
Aleksandar
I am sorry for such a late reply to your request.
This seems to be a case-sensitivity issue. You should go to Tools->Options->Output->Output Settings and make sure Case sensitive option is checked. Then try compiling the project again.
Best regards,
Aleksandar
Web Department Manager
Re: Compiler error
Good day Aleksandar
Thank you for your answer. I checked "Case sensitive" option. No result. But I found workaround for my first question. I just change the follow
void HardwareSelectBank (PHARDWARE pHardware, UCHAR bBank )
{
HW_WRITE_BYTE( pHardware, (UCHAR)REG_BANK_SEL_OFFSET, bBank );
pHardware->m_bBank = bBank;
}
to
void HardwareSelectBank (PHARDWARE pHardware, UCHAR bBank )
{
PHARDWARE ph;
ph = pHardware;
HW_WRITE_BYTE( ph, (UCHAR)REG_BANK_SEL_OFFSET, bBank );
ph->m_bBank = bBank;
}
Not very beauty, but it's good for me.
The second problem is't resolve yet. Please, just try to compile the follow little code by MikroC:
const char ml[] = {0x48, 0x54, 0x54, 0x50};
struct FILE_ENTRY { int sector_data[10]; };
typedef struct FILE_ENTRY file_entry;
file_entry FAT[10] = { {(int)ml} };
void main(void)
{while(1) {;}}
If you can do that successfully, please talking me how.
Have a nice day,
Berkl
Thank you for your answer. I checked "Case sensitive" option. No result. But I found workaround for my first question. I just change the follow
void HardwareSelectBank (PHARDWARE pHardware, UCHAR bBank )
{
HW_WRITE_BYTE( pHardware, (UCHAR)REG_BANK_SEL_OFFSET, bBank );
pHardware->m_bBank = bBank;
}
to
void HardwareSelectBank (PHARDWARE pHardware, UCHAR bBank )
{
PHARDWARE ph;
ph = pHardware;
HW_WRITE_BYTE( ph, (UCHAR)REG_BANK_SEL_OFFSET, bBank );
ph->m_bBank = bBank;
}
Not very beauty, but it's good for me.
The second problem is't resolve yet. Please, just try to compile the follow little code by MikroC:
const char ml[] = {0x48, 0x54, 0x54, 0x50};
struct FILE_ENTRY { int sector_data[10]; };
typedef struct FILE_ENTRY file_entry;
file_entry FAT[10] = { {(int)ml} };
void main(void)
{while(1) {;}}
If you can do that successfully, please talking me how.
Have a nice day,
Berkl
___________________________________________
http://www.techno-spectr.ru/en/main-en/
Yaroslavl, Russia
http://www.techno-spectr.ru/en/main-en/
Yaroslavl, Russia
Re: Compiler error
Hi,
What you were trying to do has no logic in C nor C++ language. Copying array to array is not allowed, unless you use C++ and override "=" operator.
So, if you want to avoid using some iterator loops for initialization inside main, you should consider the following workaround:
Maybe some other C compiler introduced some unorthodox C initialization technique, where this was possible to compile.
Best regards,
Aleksandar
What you were trying to do has no logic in C nor C++ language. Copying array to array is not allowed, unless you use C++ and override "=" operator.
So, if you want to avoid using some iterator loops for initialization inside main, you should consider the following workaround:
Code: Select all
const char ml[] = {0x48, 0x54, 0x54, 0x50};
struct FILE_ENTRY {
int sector_data[10];
};
typedef struct FILE_ENTRY file_entry;
file_entry FAT[10] = {
{(int)ml[0], (int)ml[1], (int)ml[2], (int)ml[3]}
};
void main(void){
while(1) {
;
}
}
Best regards,
Aleksandar
Web Department Manager