implicit/explicit __gc/__nogc confusion wrapping a windows api

  • Thread starter Thread starter Achim Domma (Procoders)
  • Start date Start date
A

Achim Domma (Procoders)

Hi,

I still try to implement a .Net wrapper to handel AVI Files. I'm unsing
managed C++ with VStudio 2003. The structure of my classes looks like this:

class AudioStream {
...
}

class VideoStream {
...
}

class AviFile {
IAVIFile* file_;
AudioStream* audio_;
VideoStream* video_;

public:
void Open(const char* path) {
AVIFileOpen(&file_,path,OF_SHARED_DENY_WRITE,NULL);
audio_ = new AudioStream();
video_ = new VideoStream();
}
}

audio_ and video_ are pointers to unmanaged classes and, according to
the documentation, are therefore implicit unmanaged pointers. But what
about file_?

The call to AVIFileOpen results in the error "'AVIFileOpenA' : cannot
convert parameter 1 from 'IAVIFile* __gc*' to 'PAVIFILE*'. AVIFileOpen
is a windows function defined in Vfw.h.

How do I have to define file_ to get my example working?

regards,
Achim
 
Achim said:
Hi,

I still try to implement a .Net wrapper to handel AVI Files. I'm unsing
managed C++ with VStudio 2003. The structure of my classes looks like this:

class AudioStream {
...
}

class VideoStream {
...
}

class AviFile {
IAVIFile* file_;
AudioStream* audio_;
VideoStream* video_;

public:
void Open(const char* path) {
AVIFileOpen(&file_,path,OF_SHARED_DENY_WRITE,NULL);
audio_ = new AudioStream();
video_ = new VideoStream();
}
}

audio_ and video_ are pointers to unmanaged classes and, according to
the documentation, are therefore implicit unmanaged pointers. But what
about file_?

The call to AVIFileOpen results in the error "'AVIFileOpenA' : cannot
convert parameter 1 from 'IAVIFile* __gc*' to 'PAVIFILE*'. AVIFileOpen
is a windows function defined in Vfw.h.

How do I have to define file_ to get my example working?

regards,
Achim

I takte it that in reality AviFile is a __gc class?

If so, since file is a member of a __gc class, the address of it is a
__gc*. You need to pin it before handing it over to the AVIFileOpen API.

If not there is somegting else relevant in your code that you are not
showing.

Ronald Laeremans
Visual C++ team
 
Back
Top