Compile error C3641

W

Wayne Allen

I am receiving a compile error when attempting to include Directshow in a
managed C++ program using Visual C++ 2005 Express Edition Version 8. The
..NET framework is version 2.0.50727. To recreate the error, do the
following steps in Visual C++ 2005 Express Edition:
1. Create a new Windows Forms Application called "Test".
2. In Form1.h, after the #pragma once declaration, add the line "#include
<dshow.h>".
3. Add the Platform SDK and DirectX include folders to the project (I am
using the DirectX 9 SDK from August 2005).
4. Build the solution.

I get a whole lot of errors along the lines of "C:\Program Files\Microsoft
Platform SDK\Include\strsafe.h(431) : error C3641: 'StringCchCopyA' :
invalid calling convention '__stdcall ' for function compiled with /clr:pure
or /clr:safe". I know that I am mixing managed and unmanaged code in my
project. Do I need to create another unmanaged class and include Directshow
in that class? If so, how would I declare such a class? Or do I need to
change my compiler settings?

Any assistance anyone could provide would be much appreciated. If you need
more information, let me know.

Thanks a lot.
Wayne
 
A

Arnaud Debaene

Wayne said:
I am receiving a compile error when attempting to include Directshow
in a managed C++ program using Visual C++ 2005 Express Edition
Version 8. The .NET framework is version 2.0.50727. To recreate the
error, do the following steps in Visual C++ 2005 Express Edition:
1. Create a new Windows Forms Application called "Test".
2. In Form1.h, after the #pragma once declaration, add the line
"#include <dshow.h>".
3. Add the Platform SDK and DirectX include folders to the project (I
am using the DirectX 9 SDK from August 2005).
4. Build the solution.

I get a whole lot of errors along the lines of "C:\Program
Files\Microsoft Platform SDK\Include\strsafe.h(431) : error C3641:
'StringCchCopyA' : invalid calling convention '__stdcall ' for
function compiled with /clr:pure or /clr:safe".
Well, the error message seems pretty explanatory to me : You are mixing
managed and unmanaged code, so you need to compile with /clr switch, not
with /clr:pure nor /clr:safe : Change your project settings to build a mixed
mode assembly.

Arnaud
MVP - VC
 
W

Wayne Allen

Oh my god...I was having such a blonde moment!! Thanks so much for your
quick response and help.
 
C

Carl Daniel [VC++ MVP]

Wayne said:
Oh my god...I was having such a blonde moment!! Thanks so much for
your quick response and help.

You may also want to make sure that DirectShow is parsed as unmanaged:

#pragma managed(push,off)
#include <dshow.h>
#pragma managed(pop)

-cd
 

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