|
I have project which I am compiling with /clr. I have a class like below..
ref class A
{
public:
void CheckValue(void * test);
typedef ref struct val
{
std::string *x;
}val_t;
};
in my implementation I ahve to use something like below..
void A::CheckValue(void *test)
{
a::val_t^ allVal = (a::val_t^)test;
}
in my main I have used like..
int main()
{
A^ obj = gcnew A();
a::val_t valObj = new std::string("Test");
obj->CheckValue((void*)valObj);
}
I am getting type cast error and two places - obj->CheckValue((void*)valObj); and at obj->CheckValue((void*)valObj); error C2440: 'type cast' : cannot convert from 'void*' to 'A::val_t ^'
This snippet is just to show behavior at my end and I ahve to use it this way only. Earlier I was running it using non /clr so it compiled fine.
Now question I have how can I make this type casting work in C++/CLI type project?
|
|
|
|
|
|
As we know C++ disdains poor typing. Some day it will achieve Pascal or Ada greatness!
Try:
desired_ptrtype newone=static_cast<desired_ptrtype>(voidstarptr)
Daniel Kilsdonk
|
|
|
|
|
Getting Access Violation Exception when trying to convert unmanaged array of structures into managed in Vb.Net(VS2010,4.0 framework) in Windows 7 -64 bit mode.
Sample Source Code
<structlayout(layoutkind.sequential, charset:="CharSet.Ansi)"> _
Public Class vb_menu_dotnet
Public level As Short
Public menu_id As String
Public short_desc As String
Public parent_id As String
Public access As Short
Public flag As Short
Public menu_desc As String
End Class
Dim current As IntPtr
Dim outArray As IntPtr
Dim manArray(100) As vb_menu_dotnet
vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call
current = outArray
Dim j As Integer
For j = 1 To 100
manArray(j) = New vb_menu_dotnet()
Marshal.PtrToStructure(current, manArray(j)) //Access Violation Exception
Vijay
|
|
|
|
|
You may need to try a VB.NET forum. This is for C++/CLI code.
|
|
|
|
|
Dim current As IntPtr
Dim outArray As IntPtr
Dim manArray(100) As vb_menu_dotnet
vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call
You have not initialised any of the pointers that you are sending to the C-language library. Take a look at this P/Invoke tutorial[^] for more information.
Use the best guess
|
|
|
|
|
Hi ,
whatever database u r acessing or data retrieval policy u might be using for e.g INI file,must be in Read Mode,Try to make it Write protected
|
|
|
|
|
Did you actually read the OP's question?
Use the best guess
|
|
|
|
|
Hi ,
whatever database u r acessing or data retrieval policy u might be using for e.g INI file,must be in Read Mode,Try to make it Write protected
|
|
|
|
|
can anyone help me finding the source code or the simulation of the Dual Busy Tone Multiple Access (DBTMA) protocol ????
regards...
|
|
|
|
|
|
Thanks alot, but i need a simulation for any BTMA, DBTMA or DUCHA .
i've a similar project based on multi-channel and busy tones.
regards
|
|
|
|
|
Well you could always refine the Google search that I created, which was based on the exact content of your question.
Use the best guess
|
|
|
|
|
All these search results are papers, but i need a written code
|
|
|
|
|
3bood.ghzawi wrote: i need a written code Well if you cannot find it by searching the internet then you will have to write it yourself.
Use the best guess
|
|
|
|
|
You have the patience of Job on this forum.
|
|
|
|
|
Not always.
Use the best guess
|
|
|
|
|
Hey.
I am trying to get my program to display only 2 decimals of the result og an calculation.
Code:
dansk = System::Convert::ToDouble(textBox2->Text);
kurs = System::Convert::ToDouble(numericUpDown1->Text);
tysk = dansk / kurs;
ti = tysk * 0.90;
femten = tysk * 0.85;
tyve = tysk * 0.82;
bdansk = tysk * kurs * 1.25;
bti = tysk * 0.90 * 1.25;
bfemten = tysk * 0.85 * 1.25;
btyve = tysk * 0.82 * 1.25;
btysk = tysk * 1.18;
label7->Text = System::Convert::ToString(dansk) + " Kr";
label8->Text = System::Convert::ToString(ti) + " Kr";
label9->Text = System::Convert::ToString(femten) + " Kr";
label10->Text = System::Convert::ToString(tyve) + " Kr";
label14->Text = System::Convert::ToString(bdansk) + " Kr";
label15->Text = System::Convert::ToString(bti) + " Kr";
label16->Text = System::Convert::ToString(bfemten) + " Kr";
label17->Text = System::Convert::ToString(btyve) + " Kr";
label20->Text = System::Convert::ToString(tysk) + " Eur";
label21->Text = System::Convert::ToString(btysk) + " Eur";
My ints are defined another place in my prpgram.
Right now my result will be something like 54.867563547, and not 54.86, as my wish is.
Can you help ?
|
|
|
|
|
|
I need a bit more then that... its my second C++ program..
|
|
|
|
|
There are lots of samples in the two links I gave you, that show how you can get your output formatted correctly. This may only be your second program but you need to get familiar with the documentation as soon as possible.
For the record you would show the Danish kroner sample as:
label7->Text = String.Format("{0:N} Kr", dansk);
However, if you look at the second link it explains how to get a number shown in different currencies automatically, by selecting the appropriate locale.
Use the best guess
|
|
|
|
|
I am sorry... But I aint getting anything out of what is explained in the links.
I tried to use the: label7->Text = String.Format("{0:N} Kr", dansk); as you said.
I just get a lot of errors:
warning C4832: token '.' is illegal after UDT 'System::String'
error C2275:'System::String' : illegal use of this type as an expression
error C2228: left of '.Format' must have class/struct/union
I guess its when I remove the Convert part of the line the problem comes ?
|
|
|
|
|
That does not look like C++/CLI code to me; more like C#. I guess you didn't look too closely at the example code[^].
Use the best guess
|
|
|
|
|
I am using Microsoft Visual Studio 2010
|
|
|
|
|
And what is the relevance of that? You do realise that Visual Studio is a development environment and not a programming language?
Use the best guess
|
|
|
|