Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi in my proj
C++
MyClass::Func01(UINT32 param1, UINT32 param2)
{

UINT8* invalBuf = NULL; // System::IntPtr^ invalBuf = NULL; even uncommenting and usage of above would give the same error.
Error	8	error C2059: syntax error : ';'	e:\Proj\ManagedProject.cpp	232
UINT8* outvalBuf = NULL; // System::IntPtr^ outvalBuf = NULL;
Error	9	error C2059: syntax error : ';'	e:\Proj\ManagedProject.cpp	232

UINT16 var1;
UINT32 var2;
.....

when invoking gcnew with above variables, and allocation of memory,

invalBuf = (System::IntPtr) gcnew(var1,true,"invalBuf");
...
memcpy(outBuf,inBuf,var1);
//error C2440: 'type cast' : cannot convert from 'System::IntPtr ^' to 'void *'	e:\Proj\ManagedProject.cpp	249	


outvalBuf[2] = Some bitwise operated value;
Error	13	error C3915: 'System::IntPtr' has no default indexed property (class indexer)	e:\Proj\ManagedProject.cpp	252

outvalBuf[3] = some other bitwise operted values;
....
	
....
....

I need to resolve the errors given correponding to each statements, I am using Managed C++, and using gcnew for allocation of memory, Even if I use System::IntPtr^ has handler, I could not overcome the above error. Any Help in resolving the above would be appreciable.

Also, I am using VS2008 IDE, Win 7 SP1 O/S.

With Regards,
Samanth_90
Posted
Updated 20-Mar-12 20:03pm
v2
Comments
Sergey Alexandrovich Kryukov 21-Mar-12 2:11am    
Did you at least try to read something on the C++/CLI as opposed to C++? This is not that trivial...
--SA
Sergey Alexandrovich Kryukov 21-Mar-12 2:12am    
Yes, compiler error messages can be very misleading... sorry.
--SA

1 solution

This code is a mess, nearly beyond repair. First thing you should know: C++/CLI analog of pointer is the manager reference, use '^' instead of '*'.

Generally, if you use C++/CLI, remember that it is pretty far from C++, even though you can combine both. So, instead of starting based on you C++ experience, read a good deal about the C++/CLI language.

Please see:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[^],
http://msdn.microsoft.com/en-us/library/dtefa218.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900