Re: C++ virtual function compiler issue
- From: "DarthDev" <DarthDev@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 1 Aug 2005 13:59:05 -0700
If proper C++ runtime initialization does not occur, such as the
initialization of the virtual function table, then when the pointer to the
virtual function is executed, an access violation occurs because the pointer
to the virtual function was not initialized to the proper function in the
derived class. That would explain what's going on.
DarthDev
--
Let it be written. Let it be done.
"Paul G. Tobey [eMVP]" wrote:
> Yes, what does that have to do with whether the call itself or processing of
> the parameters or code inside the function is generating the error?
>
> Paul T.
>
> "DarthDev" <DarthDev@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:BB6B05EF-04E5-4FDE-8169-3B4180248C4F@xxxxxxxxxxxxxxxx
> > Did you read what Steve Maillet replied to the post? I am writing a
> > Service
> > DLL exposing the proper streams interface functions.
> >
> > Thanks,
> >
> > DarthDev
> > --
> > Let it be written. Let it be done.
> >
> >
> > "Paul G. Tobey [eMVP]" wrote:
> >
> >> That's what I'm wondering. It's the *call* that's generating the error
> >> (watch it execute in the debugger in disassembly mode), or the processing
> >> of
> >> the code in the call, or processing of parameters or return values?
> >>
> >> Paul T.
> >>
> >> "DarthDev" <DarthDev@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:75170C16-3842-475B-A792-DAD5DE1D86E2@xxxxxxxxxxxxxxxx
> >> > Sorry about that. When the virtual function ProcessUserRequest is
> >> > called,
> >> > is
> >> > when the acces violation exception is genereated with in the kernel
> >> > debugger.
> >> > My hardware is the Arcom Viper board equipped with an Intel Xscale
> >> > PA255
> >> > processor.
> >> >
> >> > Thanks,
> >> >
> >> > DarthDev
> >> >
> >> > --
> >> > Let it be written. Let it be done.
> >> >
> >> >
> >> > "Paul G. Tobey [eMVP]" wrote:
> >> >
> >> >> A little more detail, please. "When it's called"? Are you saying
> >> >> that,
> >> >> in
> >> >> the kernel debugger, when you attempt to step into a call something
> >> >> like
> >> >> this:
> >> >>
> >> >> LogService ls = new LogService();
> >> >> ls->Write();
> >> >>
> >> >> there's an immediate exception?
> >> >>
> >> >> What processor would also be important information. Is inlining
> >> >> enabled?
> >> >>
> >> >> Paul T.
> >> >>
> >> >> "DarthDev" <DarthDev@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> >> news:C2603B68-C523-48AC-BDF3-DA5D6E34712E@xxxxxxxxxxxxxxxx
> >> >> >I was coding up a service in C++ that is compiled in Platform Builder
> >> >> >when
> >> >> >I
> >> >> > came a cross this compiler issue. Here is a code example.
> >> >> >
> >> >> > class Service
> >> >> > {
> >> >> > public:
> >> >> > void Write();
> >> >> > virtual bool ProcessUserRequest(
> >> >> > unsigned char * UserMessage,
> >> >> > unsigned int UserMessageSize)=0;
> >> >> > };
> >> >> >
> >> >> > Service::Write()
> >> >> > {
> >> >> > unsigned char Buffer[256];
> >> >> >
> >> >> > bool Result=ProcessUserRequest(BufferSize,256);
> >> >> > }
> >> >> >
> >> >> > class LogService : public Service
> >> >> > {
> >> >> > virtual bool ProcessUserRequest(
> >> >> > unsigned char * UserMessage,
> >> >> > unsigned int UserMessageSize);
> >> >> > }
> >> >> >
> >> >> > bool LogService::ProcessUserRequest(
> >> >> > unsigned char * UserMessage,
> >> >> > unsigned int UserMessageSize)
> >> >> > {
> >> >> > int x;
> >> >> > x=1;
> >> >> > return(true);
> >> >> > }
> >> >> >
> >> >> > When the LogService class is instantiated in a service stream
> >> >> > interface
> >> >> > DLL
> >> >> > and Write() method is called, an access violation exception is
> >> >> > generated.
> >> >> > To
> >> >> > my knowledge this is good C++ code. I have compiled this code in
> >> >> > Embedded
> >> >> > Visual C++ and it executes fine. I am wondering if the compiler
> >> >> > goofing
> >> >> > up
> >> >> > the virtual function table.
> >> >> >
> >> >> > Thanks,
> >> >> >
> >> >> > DarthDev
> >> >> >
> >> >> > --
> >> >> > Let it be written. Let it be done.
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
.
- Follow-Ups:
- Re: C++ virtual function compiler issue
- From: Steve Maillet \(eMVP\)
- Re: C++ virtual function compiler issue
- References:
- Re: C++ virtual function compiler issue
- From: DarthDev
- Re: C++ virtual function compiler issue
- From: Paul G. Tobey [eMVP]
- Re: C++ virtual function compiler issue
- From: DarthDev
- Re: C++ virtual function compiler issue
- From: Paul G. Tobey [eMVP]
- Re: C++ virtual function compiler issue
- Prev by Date: Re: C++ virtual function compiler issue
- Next by Date: Re: C++ virtual function compiler issue
- Previous by thread: Re: C++ virtual function compiler issue
- Next by thread: Re: C++ virtual function compiler issue
- Index(es):
Relevant Pages
|