Repost - weird behaviour with function declaration

W

Wild Wind

Hello,

I posted this a few days back, but got no response, so I
am reposting it.

I have an event in my managed class which I declare as:

__event void MyEvent(System::Byte (*fir) __gc[]);

However, I find that when I build the class, I get very
strange errors like

error C2143: syntax error : missing ')' before ';'

I think the problem has to do with my declaration, because
when I redeclare the event as

__event void MyEvent(System::Byte fir __gc[]);

the error goes away. However, I don't feel satisfied with
this because I don't see a problem with the declaration.

In addition, this event is going to be consumed by a VB.NET
application and since the array it is passing as a parameter
is a managed array, I have to pass a pointer to the array
instead of the array itself as I do in the 'corrected'
version.

I would appreciate it if anyone could shed some more
light on the correct way to raise events that have arrays
as parameters. Should I just use System::Array* instead?
 
V

Vinayak Raghuvamshi

Wild Wind said:
Hello,

I posted this a few days back, but got no response, so I
am reposting it.

I have an event in my managed class which I declare as:

__event void MyEvent(System::Byte (*fir) __gc[]);

However, I find that when I build the class, I get very
strange errors like
......

Hi. I am not really sure what you are trying to do with your events.
But forgetting events for the moment, if what you intend is to declare
a pointer to an array, they your declaration is wrong.

try something like:

typedef System::Byte MyByteArray __gc[];

and then use it like __event void MyEvent(MyByteArray *array);

NB: I am just pointing you in the right direction as far as declaring
a pointer to your array goes... I have no clues what your VB client
expects or how you are implementing the event etc....

hth.
-Vinayak
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top