Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error. Privileged instruction...

Status
Not open for further replies.

LoneRanger123

Programmer
Dec 19, 2000
62
GB
Suddenly out of the blue a peice of code that has been working fine has suddenly given an error. I have a function defined as....

void __fastcall TSidebar::make_dir_listing(TObject *Sender)
{

and declared as...

public: // User declarations
__fastcall TSidebar(TComponent* Owner);
void __fastcall make_dir_listing(TObject *Sender);



I have been adding code to a completely unrelated part of the program, but when I run it it gives and EPrivilege error and the line pointer (blue) goes to the Start of that function.

I dont know why, the code I have added is working with emails and doesnt call that function,also commenting out all the new code doesnt work. I saved the file by accident so I can get the old code which did work, but here is the new stuff

Code:
void __fastcall TSidebar::ButEmailClick(TObject *Sender)
{
/*
 state = 4;
//SET LIST IMAGEINDEX
LIST->SmallImages = ImgLstEmail;

int ct = 0; //Count current Message
if (EMAIL->Tag == 1)
EMAIL->Disconnect();   //IF CONNECTED DISCONNECT

EMAIL->Connect();
EMAIL->List();

LIST->Items->Clear();
while (ct < NoMessages) {
  EMAIL->GetMailMessage(Emails[ct].ID);

  ct++;
}
  MessageDlg(&quot;CONNECTED&quot;,mtInformation,TMsgDlgButtons() << mbOK,0);

 */
}
//---------------------------------------------------------------------------

void __fastcall TSidebar::EMAILList(int Msg, int Size)
{
/*
  Emails[NoMessages].ID = Msg;

  NoMessages = NoMessages + 1;
    MessageDlg(Msg,mtInformation,TMsgDlgButtons() << mbOK,0);
    */
}
//---------------------------------------------------------------------------

void __fastcall TSidebar::EMAILConnect(TObject *Sender)
{
//EMAIL->Tag = 1; //SET THE STATUS TO CONNECTED
}
//---------------------------------------------------------------------------

void __fastcall TSidebar::EMAILSuccess(TObject *Sender)
{
/*    MessageDlg(&quot;Hello&quot;,mtInformation,TMsgDlgButtons() << mbOK,0);
           TListItem *ListItem;
           String ItemName;
           ListItem = LIST->Items->Add();

        ItemName = EMAIL->MailMessage->Subject;

    if (ItemName.Length() > 20) {
        ItemName.SetLength(17);
        ItemName = ItemName + &quot;...&quot;;
    }
       ListItem->Caption = ItemName;

     ListItem->ImageIndex = 0;
     */
}
 
Did you find any solution to this?
The same thing has been driving me nuts!
Cheers,
Douglas JL

Common sense is what tells you the world is flat.
 
Sometimes if you miss a semicolon or have some other
syntax error the line pointer for the error will show up in some very weird places totally unrelated to the function you are working on. Its kinda like when the actuall place the error is at will occur on the line previous to the line pointed to. The compiler will show the first instance of where it detects a fault. If I put mud in your coffee you will not detect it until you drink it. Dont wory about where the linepointer ends up at. The error is in the code you have been modifying recently.
 
Cheers, man - it turned out that this is some kind of wierd bug.
lastcyborg explained in a related post that the compiler is trying (from no fault of the coder, as far as we can tell) to place two variables in the same memory location.
The work-around for this is to identify which variables it cuold be happening & declare them elsewhere.
This wouldn't have worked for me, cuz they were declared in a class definition, so I simply altered the order of their declaration. This allowed a compile to finish.
The problem hasn't vanished, though. Every time it occurs, I simply swap a couple of variable declarations around & everything is hunky-dory again.
A bit of a drag, but better than a kick in the teeth & a 2 days' work ruined.
Cheers,
DJL Common sense is what tells you the world is flat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top