Compiler error

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Berkl
Posts: 124
Joined: 05 May 2009 13:09
Location: Russia
Contact:

Compiler error

#1 Post by Berkl » 25 Feb 2010 11:11

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
___________________________________________
http://www.techno-spectr.ru/en/main-en/

Yaroslavl, Russia

Berkl
Posts: 124
Joined: 05 May 2009 13:09
Location: Russia
Contact:

Re: Compiler error

#2 Post by Berkl » 25 Feb 2010 15:52

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
___________________________________________
http://www.techno-spectr.ru/en/main-en/

Yaroslavl, Russia

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

Re: Compiler error

#3 Post by anikolic » 03 Mar 2010 16:11

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
Web Department Manager

Berkl
Posts: 124
Joined: 05 May 2009 13:09
Location: Russia
Contact:

Re: Compiler error

#4 Post by Berkl » 03 Mar 2010 21:24

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
___________________________________________
http://www.techno-spectr.ru/en/main-en/

Yaroslavl, Russia

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

Re: Compiler error

#5 Post by anikolic » 04 Mar 2010 16:26

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:

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) {
  ;
  }
}
Maybe some other C compiler introduced some unorthodox C initialization technique, where this was possible to compile.

Best regards,
Aleksandar
Web Department Manager

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”