im trying to make just ANY dll right now that works
//in the dlltest.h file
#ifndef DLLTEST_H_
#define DLLTEST_H_
__declspec(dllexport) int asdfness(int asdf);
#endif
//in the dlltest.cpp file
#include "dlltest.h"
__declspec(dllexport)
int asdfness(int asdf) {
int lolz = 0;
lolz = asdf + 3000;
return lolz;
}
and it keeps saying entry point not found. and i looked at about 100 different sites and they all said the same exact thing. soooo... anyone see anything wrong with this code? i'm a big noobie so i bet it's a syntax error or something
are you calling it from VB? if so do this:
extern "C" {
__declspec(dllexport)
int asdfness(int asdf) {
int lolz = 0;
lolz = asdf + 3000;
return lolz;
}
}
extern C will compile it as a C function without adding extra crap to your export name, also you don't need the header file.
just tried that. it now gives me an error "bad dll calling convention"... grr
Quote from: brew on June 01, 2007, 08:23 PM
just tried that. it now gives me an error "bad dll calling convention"... grr
yeah VB sucks, it works if you compile the prog though.
just tried. it worked (thank god) but it gave me the unexpected result. "1697" when it was supposed to be "3005"
mind uploading your calling program, and your dll?
sure. http://zenixstudios.com/f.php?f=xjskjkpo
Private Declare Function asdfness Lib "dlltest" (asdf As Integer) As Integer
Private Sub Form_Load()
Dim asdf As Integer
asdf = 5
asdf = asdfness(asdf)
MsgBox asdf
End Sub
extern "C" {
int __declspec(dllexport) asdfness(int asdf) {
int lolz = 0;
lolz = asdf + 3000;
return lolz;
}
}
aha your call is the problem gotta ByVal asdf
Crashes now. Really bad, too. It freezes for like 6-7 seconds before i get the error message
Perhaps i should change the arguments in the dll?
did you change the arguments?
yes. in my call.
doesn't matter now, i was able to get char * arguments working properly (i'm suprised) :-D
muwhahahahaha
has to be __stdcall for vb to work w/ it.
oh? it works without _stdcall when compiled though. might be something with the pcode when you test in the ide.
**edit
using _stdcall makes it not work at all... now it says entry point not found. :-(
Don't know how you have it working, must be a coincedence or something because the only calling convention that VB understands is __stdcall.
He is doing this:
Declare Function "test" lib "testdll" () As Long
in C++:
extern "C"
{
__declspec(dllexport) int test()
{
return 5;
}
}
exports function "test"
however,
__declspec(dllexport) int __stdcall test()
{
return 5;
}
exports function "_test@16"
hence trying to call test, when the name compiled is _test@16 would return entry point not found.
Ugh, add a definition file.
http://www.digitalmars.com/ctg/ctgDefFiles.html#exports
Quote from: UserLoser on June 02, 2007, 12:40 PM
Ugh, add a definition file.
http://www.digitalmars.com/ctg/ctgDefFiles.html#exports
right, but that's something he obviously doesn't have.
I've tried using a definition file at least 3 times before, and they just plain don't work. Am I doing something wrong? And I know the linker is recognizing them. I've gotten some errors with it apparently interfering with the __stdcall
Quote from: UserLoser on June 02, 2007, 12:40 PM
Ugh, add a definition file.
http://www.digitalmars.com/ctg/ctgDefFiles.html#exports
According to Microsoft, a .def file shouldn't be necessary if you use __declspec(dllexport).
Quote from: brew on June 01, 2007, 09:37 PM
sure. http://zenixstudios.com/f.php?f=xjskjkpo
Private Declare Function asdfness Lib "dlltest" (asdf As Integer) As Integer
Private Sub Form_Load()
Dim asdf As Integer
asdf = 5
asdf = asdfness(asdf)
MsgBox asdf
End Sub
extern "C" {
int __declspec(dllexport) asdfness(int asdf) {
int lolz = 0;
lolz = asdf + 3000;
return lolz;
}
}
Coincidentally, the Visual Basic Integer and the C int type are two very different things.
yes, int in C is a 32bit integer, it's a 16bit integer in VB.
Quote from: l2k-Shadow on June 03, 2007, 10:07 PM
yes, int in C is a 32bit integer, it's a 16bit integer in VB.
C does not define a standard size for int. Most compilers implement as a 32-bit value. However, some may implement it as 16.
Then what's a long (by default) ?
I'm using Visual C++....
Quote from: brew on June 06, 2007, 09:24 PM
Then what's a long (by default) ?
I'm using Visual C++....
check using sizeof()
#include <iostream.h>
void main()
{
cout << "Int: " << sizeof(int) << "\n" << "Long: " << sizeof(long) << "\n";
}
what the hell! so in VC++ an integer and a long are the same size.. what is the difference between the two? also what does VC++ use for a big endian 2 byte data type?
have to write a converting function if you're on a little endian system.
Quote from: brew on June 07, 2007, 08:26 AM
what the hell! so in VC++ an integer and a long are the same size.. what is the difference between the two? also what does VC++ use for a big endian 2 byte data type?
Since VC++ only targets Windows and Windows runs on little-endian systems only, VC++ does not use a big-endian 2-byte type.
Standard 2-byte type is short int.
These are the numeric types and macros defined in by the Windows platform SDK:
char = CHAR = signed 8-bit
unsigned char = BYTE = unsigned 8-bit
short int = SHORT = signed 16-bit
unsigned short int = WORD = unsigned 16-bit
long int = LONG = signed 32-bit
unsigned long int = DWORD = unsigned 32-bit
long long int = LONGLONG = __int64 = signed 64-bit
unsigned long long int = ULONGLONG = __uint64 = unsigned 64-bit
For a 64 bit data type couldn't you also just use a double?
Quote from: brew on June 08, 2007, 07:10 AM
For a 64 bit data type couldn't you also just use a double?
yes but double is a floating point number.
it could still store up to 2^64 in whole numbers with no decimals, right? Theoretically?
Quote from: brew on June 08, 2007, 12:11 PM
it could still store up to 2^64 in whole numbers with no decimals, right? Theoretically?
no
Quote from: brew on June 08, 2007, 12:11 PM
it could still store up to 2^64 in whole numbers with no decimals, right? Theoretically?
Using a double invokes the floating point coprocessor. That means that the floating point unit is going to use a mantissa and floating point section. So no.