Jump to content
Andrew Leiper

Access Violation For Const Struct

Recommended Posts

Hi Pavel,

 

boostc v7.01

PIC18F2525

Windows XP

 

The following code generates an "Access violation at 0x00493221 tried to read from 0x00000000".

Changing the 300 to 0 or removing some of the |'d values allows it to compile.

 

/////////////////////////////////////////

#include <system.h>

 

typedef struct {

unsigned short w;

unsigned char d;

} TTestStruct;

 

const TTestStruct InitStruct = {

300,

(

(0 << 0) | (0 << 2) | (0 << 4)

)

};

/////////////////////////////////////////

 

Hopefully that will be it for the bug reports from me for now as my project is now compiling !! :)

Now I just have to test that it works.

 

Cheers,

 

Andy Leiper

IET Ltd

Share this post


Link to post
Share on other sites

Hi Pavel,

 

Since we are on the subject if Access Violation, here is another piece of code which generates one.

 

"0x0047032D, read from 0x0000050"

 

#include <system.h>

typedef unsigned char	BYTE;
typedef unsigned int 	WORD;

typedef union
{
WORD Val;
BYTE v[2];
} WORD_VAL;

void main()
{
WORD ChunkLen;

myDWord.Val = 0;

if(((WORD_VAL*)&ChunkLen)->bits.b0)
{
	ChunkLen++;
}
}

 

SB 7.01, PIC18F4580, XP Pro SP3.

 

It is not SB code, but, like Andrew I am doing a MChip C18 port.

 

Cheers

 

Reynard

 

ps. ignore the myDWord.Val = 0; bit of code.

Edited by Reynard

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...