|
|
How are you binding to the DLL at runtime -
early (using a link library) or late (using LoadLibrary() at runtime)?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am binding early (using an import library).
|
|
|
|
|
|
I'm trying to build an app which displays proprietary binary data on a virtual grid. Since the number of rows can be in the millions, I'm trying to implement a way to filter out the undesired data. I was asked to prompt users to select filtering by way of a tree control.
My tree is 4 levels deep. At the root level, I have 8 nodes (called Bus). Each bus has 32 children nodes (called RT #). Each RT node has 2 children nodes (called Transmit / Receive). Each Transmit and Receive node has 32 children nodes (called MSG #). So top-down, my tree is essentially 8 x 32 x 2 x 32 nodes.
I have been asked to also implement this tree in such a fashion that if the user only selects a particular parent node and does not select any child node beneath this parent node, that this is to mean a wild card for all descendant nodes beneath that selected parent node.
I am doing things in MFC and it seems I cannot do a bit array. I've tried using a 4 dimensional bool array but I am forced to store true / false values utilizing all 4 dimensions (which makes it impossible to store the wildcard condition mentioned above for anything less than 4 dimensions.)
What is the best way to encapsulate the user-defined filtering right before I am about to parse through a source file on-the-fly?
|
|
|
|
|
Why not bitfields?
struct filter
{
unsigned Bus : 3;
unsigned Route : 5;
unsigned Xmit : 1;
unsigned Rcv : 1;
unsigned Msg : 5;
unsigned dummy : 1;
};
|
|
|
|
|
Hi there,
I'm trying to make a C++ DLL with non-decorated method names that can be called from .NET. I've followed the format described in several articles, but it just won't compile:
class Vdr
{
public:
extern "C" __declspec (dllexport)
int add (int a, int b);
};
I get the compile error:
Error 1 error C2059: syntax error : 'string' c:\alan\4000\vdrdll\vdrdll\vdr.h 5
which is the line with extern "C". If I take out the extern "C", it compiles, but with decorated method names. Any ideas on what the problem is? Thanks!
|
|
|
|
|
Are you not wanting to export the entire Vdr class?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, that would be fine. But the immediate problem is how to get the extern "C" attribute on a method. None of the various permutations seem to work.
|
|
|
|
|
Alan Balkany wrote: But the immediate problem is how to get the extern "C" attribute on a method.
Syntax errors aside, unless the class was also visible to the outside world, what good would that do? There's a reason that the compiler is not allowing it.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It works without any kind of export directive on the class. Maybe it's because the method is static.
|
|
|
|
|
Move the extern "C" outside of the class so that it encompasses the entire class.
extern "C"
{
class Vdr
{
public:
__declspec (dllexport)
int add (int a, int b);
};
}
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks for the suggestion, but unfortunately it still appears to be generating decorated method names.
|
|
|
|
|
OK - but it does not make sense for the method names to be exported in C format, because (member) methods are specific to C++.
Perhaps you want to export simple functions (no references!) and have them in undecorated names?
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
That's what I decided to do; according to Nemanja (above) extern "C" cannot be applied to members of a class; just functions.
=================
BTW, in case anyone's interested, I just figured out how to pass objects from C# to C++:
BitmapInfo bi = new BitmapInfo ();
IntPtr ptr = (IntPtr) (&bi);
CppFunction (ptr);
|
|
|
|
|
You can lead a horse to water but you can't make him fish
led mike
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Alan Balkany wrote: I'm trying to make a C++ DLL with non-decorated method names that can be called from .NET.
Are you trying to use a native C++ class from .NET? Can't do that. Either make a COM wrapper, a C++/CLI one, or export the functionality from the DLL with plain C functions.
The specifier extern "C" can be used only on non-member functions, and besides the exported functions will still be decorated, although in a different way.
|
|
|
|
|
Ah, so what I was trying is impossible. Thanks.
Apparently static methods can be used from .NET, although they're decorated. I think I'll take your suggestion and use C functions.
|
|
|
|
|
i want to read a file and input each record by record into shared memory .
|
|
|
|
|
Nice intention, get to work!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Your question relates to what ? using fgets or using shared memory ?
|
|
|
|
|
yes,i want to put the data to shared memory and by using another process need to read them
|
|
|
|
|
I am trying to enumarate an USB device. This is a regular flash drive. I am using this piece of code
int main(void)
{
GUID USBIODS_GUID;
USBIODS_GUID.Data1 = 0x4D36E967;
USBIODS_GUID.Data2 = 0xE325;
USBIODS_GUID.Data3 = 0x11CE;
USBIODS_GUID.Data4[0] = 0xBF;
USBIODS_GUID.Data4[1] = 0xC1;
USBIODS_GUID.Data4[2] = 0x08;
USBIODS_GUID.Data4[3] = 0x0;
USBIODS_GUID.Data4[4] = 0x2B;
USBIODS_GUID.Data4[5] = 0xE1;
USBIODS_GUID.Data4[6] = 0x03;
USBIODS_GUID.Data4[7] = 0x18;
HDEVINFO hInfo = SetupDiGetClassDevs(&USBIODS_GUID, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
for (DWORD i=0; ; ++i)
{
SP_INTERFACE_DEVICE_DATA Interface_Info;
Interface_Info.cbSize = sizeof(Interface_Info);
Enumerate device
if (!SetupDiEnumDeviceInterfaces(hInfo, NULL, (LPGUID) &USBIODS_GUID,i, &Interface_Info))
{
int err = GetLastError();
SetupDiDestroyDeviceInfoList(hInfo);
return(i);
}
}
}
I obtained the UID for this device from the registry.
The SetupDiEnumDeviceInterfaces returns ERROR_NO_MORE_ITEMS
Where have I gone wrong?
Also what is the difference between functions SetupDiEnumDeviceInterfaces () and SetupDiEnumInterfaceDevice()
|
|
|
|
|
koumodaki wrote: The SetupDiEnumDeviceInterfaces returns ERROR_NO_MORE_ITEMS
Where have I gone wrong?
By possibly not reading the documentation:
MemberIndex - Specifies a zero-based index into the list of interfaces in the device information set. The caller should call this function first with MemberIndex set to zero to obtain the first interface. Then, repeatedly increment MemberIndex and retrieve an interface until this function fails and GetLastError returns ERROR_NO_MORE_ITEMS.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|