Click here to Skip to main content
15,900,434 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C
#include <windows.h>
// This class is exported from the DLL1.dll
class DLL1_API CDLL1
{
public:
    BSTR test;
    CDLL1();
    int GetCpuSpeed();
};



Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\documents and settings\hz0ss1\my documents\downloads\dll1\dll1.h 32 1 DLL1
Posted
Updated 1-Jul-11 1:45am
v2
Comments
Philippe Mori 1-Jul-11 8:31am    
On which line/symbol the error occurs. Is DLL1_APP properly defined? Is BSTR definition included by <windows.h>?

 
Share this answer
 
should b used in C++:

Class Name : testClasss

code:

// Test Object Id Type
typedef [public, uuid(7442df10-466d-11d3-be72-0008c719118c)]
BSTR test_ObjectID;

-------------------
above code Used as In VB.Net :

code

Dim obj as testClasss.test_ObjectID

within Any function

obj = "string value"

---------------------
is this possible..?
 
Share this answer
 
Comments
Philippe Mori 1-Jul-11 8:41am    
Humm.... This post does seems to make any sense. What are you trying to do ?

By the way, it is not a good idea to try to used a C++ class from VB.NET. There are many thing that can go wrong with such a solution (class layout, memory management...) and its hard to use.
If you want to uses some C++ code from VB.NET, the best solution is to uses C++/CLI and uses managed code to interface between VB.NET and C++.

class RegularCppClass
{
};

public ref class CppCliClassForVb
{
public:
    property System::String ^Test;
    int GetCpuSpeed();

private:
    // This member cannot be used directly from VB. You will need to add 
    // appropriate member (property or method) to CppCliClassForVb.
    // Also, you will need to do proper memory management of that object
    // by properly defining finalizer and destructor as appropriate.
    RegularCppClass *regularCppClass;
};


Destructors and finalizers in Visual C++[^]

That class can uses regular C++ object if it need to. C++ object need to be allocated by pointer or reference.

If you need in some case to go the other way (a C++ class need to have an hadle to a managed object, you will need gcroot< > (http://msdn.microsoft.com/en-us/library/481fa11f(v=VS.100).aspx[^]).

By using a managed layer between your C++ code and VB, it will be much simpler to uses from VB. You will just have to add a reference to the DLL.

By the way, your C++ code will need to be compiled as managed but with support for standard C++ (assuming you want to uses regular C++ code). That is, you need the option /clr (http://msdn.microsoft.com/en-us/library/k8d11d4s.aspx[^]). This option is available in your project settings.
 
Share this answer
 
v2
<code>#include <windows.h>
#include <string.h>
#define BSTR unsigned short*</code>
 
Share this answer
 
Comments
Philippe Mori 1-Jul-11 8:34am    
Not a good idea to manually define BSTR. The proper file should be included instead.

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