Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What type is equal to C++ SHORT type?

Status
Not open for further replies.

mensud

Programmer
Jul 22, 2001
51
0
0
US
I have developed an dll in C++(my favorite language) and I want to use this dll in foxpro. I am not sure what type in FoxPro is equal to VC++ short type.

Thanks
 
If it's your .DLL, why not make it an INTEGER (4 bytes) and not worry about it?
Better yet, create a COM DLL (ActiveX) and make it much easier to inter face to VFP and other languages!

Rick
 
I know that I could change the types in dll, but I don't have the source code here, and can't wait until tomorrow.
 
mensud,

VFP also has a SHORT type and it is the same as C++

If you want to put it as a return value

eg. DECLARE .... myfunc IN mydll

Then you can use SHORT/INTEGER/LONG, they will return the same value. As you may have know that VFP is not strong typing.

-- AirCon --
 
Forgot to mentioned that you cannot use SHORT as the return value if the dll is using int/long as a return value.

-- AirCon --
 
It seems to me that vfp's SHORT would be appropriate. This is from VFP7's help, but VFP6 doesn't choke on it (though I have no function with a SHORT parameter to try...):
DECLARE - DLL Command
SHORT 16-bit integer
INTEGER 32-bit integer
SINGLE 32-bit floating point
DOUBLE 64-bit floating point
LONG 32-bit long integer
STRING Character string
OBJECT IDispatch object type (I think VFP8 only)

From C++ help:
Data Type Ranges
Type Name | Bytes | Other Names | Range of Values
int | * | signed, signed int | System dependent
unsigned int | * | unsigned | System dependent
__int8 | 1 | char, signed char | –128 to 127
__int16 | 2 | short, short int, signed short int | –32,768 to 32,767
__int32 | 4 | signed, signed int | –2,147,483,648 to 2,147,483,647
__int64 | 8 | none | –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
char | 1 | signed char | –128 to 127
unsigned char | 1 | none | 0 to 255
short | 2 | short int, signed short int | –32,768 to 32,767
unsigned short | 2 | unsigned short int | 0 to 65,535

long | 4 | long int, signed long int | –2,147,483,648 to 2,147,483,647
unsigned long | 4 | unsigned long int | 0 to 4,294,967,295
enum | * | none | Same as int
float | 4 | none | 3.4E +/- 38 (7 digits)
double | 8 | none | 1.7E +/- 308 (15 digits)
long double | 10 | none | 1.2E +/- 4932 (19 digits)
 
FYI: the page on the wiki for ApiStructureClass is now updated to correct support for SHORT and remove support for INTEGER (previously, INTEGER was incorrectly treated as a SHORT, but I think DWORD/LONG are already enough synonyms for the 4-byte integral type... INTEGER is confusing.)
 
wgcs,

INTEGER is confusing
Yes, I agree with that. But my very first reason for using LONG is because it is much shorter to type instead of INTEGER, especially in VFP6 (no intelisense [mad] ). I only use integer if from the API declaration is INT type.
But still sometimes I replace it with LONG (again, much shorter to type [wink] )

-- AirCon --
 
wgcs,

you want to try SHORT in VFP6? Look here: thread184-596608

You can also try this from VFP6 or later

Declare SHORT GetActiveWindow in User32
?GetActiveWindow()
Declare LONG GetActiveWindow in User32
?GetActiveWindow()

They will return the same value :)

-- AirCon --
 
re:
Declare Short GetKeyState in User32 Integer KeyCode

I had been using the similar GetAsyncKeyState declared as an INTEGER, and it has worked fine... I had no Idea when I wrote that code that SHORT was not the same as INTEGER...
 
Yes, I also experienced with that kind of strange things. I even got a result from one API (sorry forgot which one) that when I declared as Integer is not the same with Long (the LONG is the correct one). Especially under Windows NT based. It is the other reason why I prefer to use LONG

Regards

-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top