|
I believe that your first error is from a type that is defined 2x and differently each time. Check that in your playsound files.
|
|
|
|
|
I have fixed both problems. Thanks. I made my class all inline and that fixed my linker errors whatever they were. Case closed.
|
|
|
|
|
Has anyone implemented Albert's article, "How to open a serial COM port in Managed C++, By Albert Pascual"
After I boot up my WinXP Pro system, Albert's implementation only works after I start up HyperTerminal. After that, it works fine from then on... Any clues? Has anyone else run into this on XP.
Thanks in Advance!
|
|
|
|
|
I worked through this. The code provided in the article is not sufficient to make the serial port work properly.
icdma
|
|
|
|
|
Hi,
I am learning C++ and Windows Forms and get a strange compiler error. I am using the directX header dshow.h for my project and when I do I get this error:
error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager'
stdafx.cpp(0) : see declaration of 'System::Resources::ResourceManager'
and it points to this code:
this->ButtonImages->ImageStream = (__try_cast<System::Windows::Forms::ImageListStreamer * >(resources->GetObject(S"ButtonImages.ImageStream")));
and this was all generated by the designer.
I also get something similar when I try to use the MessageBox class. If I don't imclude dshow.h than these errors go away.
Any reasons and fixes are appreciated. Thanks.
|
|
|
|
|
That's because preprocessors are stupid. When a preprocessor finds GetObject, it replaces it with GetObjectA or GetObjectW, depending whether you compile a Unicode version or not.
Just put something like
#undef GetObject
after #include <windows.h>
and everything should work fine.
|
|
|
|
|
Hi all
HTF do you declare it? Now I know why it is called C++, like C, but you are require to do 2 things extra for every bloody thing@!!!
OK so I had this in C:
static Int32 rNums[512] = { 123,1231,....,2131};
In MC++ I try:
static Int32 rNums __gc[] = {123,1231,....,2131};
No luck, Int32 is defined. The error messages are useless as usual! Compiling as C++ with /clr.
at the declaration:
randtable.c(71) : error C2146: syntax error : missing ';' before identifier 'rNums'
randtable.c(71) : error C3150: '[' : '__gc' can only be applied to a class, struct, interface, array or pointer
at the end of the array:
randtable.c(123) : error C2501: 'leppie::RandomNumbers::rNums' : missing storage-class or type specifiers
randtable.c(123) : error C3845: 'leppie::RandomNumbers::rNums' : only static data members can be initialized inside a __gc class or value type
ANy one?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
OK I dont get this...
AT stattement level I can do this:
Int32 rNums __gc[] = {11,112,334,...,6667,8567};
But NOT at class level for a static instance. Nor can I do assignment at statement level, ie:
Int32 rNums __gc[];<br />
<br />
rNums = {11,112,334,...,6667,8567};
According to the docs the behaviour is the same as C++...
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
|
__value struct V
{
static Int32 rNums[] = { 123, 345 };
static String* names[] = { S"ABC", S"DEF" };
};
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
|
leppie wrote:
It doesnt appear to work so for a __gc class though
What exactly isn't working?
leppie wrote:
what is the difference between:
__value struct
__value class
__gc class
__gc struct
?
The only difference here is the __value will allocate a managed type on the native stack and __gc will allocated a managed type on the CLR heap.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
I tried to compile MFC project using Visual Studio .NET Architect version 7.0.9466. I used the wizerd to generate a minimal project that suport MFC. At compilation time I get the following
fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'f:\vs70builds\9466\vc\Compiler\Utc\src\P2\main.c', line 146)
When I comment out the #include <afx.h> the compilation succeded.
What happen I have an old version of VS .NET
PLEAASE can somebody help me
Cristi
|
|
|
|
|
|
Hello
I have the same problem with any project in MFC even with the ones that are generated by Wizard. I have some experience in MFC, I think that could be something with my instalation kit. So if I send you the project will not help because the problem apears with any MFC project.
|
|
|
|
|
Hey,
I am pretty new to C++ and Visual C++. Managed C++ offers Strings which are very useful. I would like to be able to copy or convert a String to a char array. I need to because I am trying to transfer this String into a function that is unmanaged and excepts char arrays.
|
|
|
|
|
<br />
#include <vcclr.h><br />
...<br />
String* s = S"Hello";<br />
const __wchar_t __pin * str = PtrToStringChars(s);<br />
By the way, this is covered in Nish's and my new book on mixing MFC and Managed C++ code. See sig if interested.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
or:
__wchar_t __pin * str = &s->ToCharArray()[0];
It's ugly, but a nice hack to convert __gc[] to *.
Note: even though the NULL character is not returned by ToCharArray(), the CLR seems to pin it in some "clear" space.
Any reason why you add the const keyword? Doesnt __pin take care of that?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
The PtrToStringChars is more efficient as it simply returns a casted pointer to the string's internal buffer. By comparison, the String::ToCharArray method creates a brand new copy of the string and returns that to the caller.
leppie wrote:
Any reason why you add the const keyword?
The PtrToStringChars function returns a const System::Char* cast of the internal string value.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
|
const has nothing to do with __pin. The former simply means that you won't change the value. The latter is used so that the CLR will not move the data in memory.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Simpler way is to use ATLMFC.
<br />
#include <atlstr.h>
<br />
String* strSomething;<br />
CString str = strSomething;
But you will need to find a way to pack your ATLMFC7.0 redistributable when you release your app.
Hope this helps.
|
|
|
|
|
How do you debug managed code that used unmanaged code? I have several managed functions that call functions that are unmanaged. If I use #pragma unmanaged on the unmanaged functions to get compiled code out of them, I can't step into them from the managed code. I have the debug properties of the project set to Mixed. Auto doesn't work either. What other settings am I missing?
TIA
|
|
|
|
|
|
I checked them to be sure and they are off for debug compile. I really haven't changed the settings much. I started a managed C++ dll project and change a few things like /noentry on, precompiled headers off, changed additional dependencies to be (odbc32.lib odbccp32.lib Netapi32.lib msvcrt.lib)
Thanks
PS also if I remove all the pragma's to make the entire thing managed code it works fine.
PSS I create a simple console .net app, added an unmanaged function and it works fine. The only difference between the 2 is one is a dll the other is an exe. I compared the setting of my dll to the console app and made sure they matched. A couple were off, but even when I changed them I still can't step in to the managed code in my dll.
|
|
|
|