-1

Someone please tell me about the difference

int* variable
int * variable
int *variable
void* variable
void** variable
char*
short variable //(C++) in c# this type more suitable with? short type too??

i have .h, .lib and .dll file but I don't know the contents of the lib and dll file
example:
this one is from header file

#ifdef cpp_EXPORTS
#define cpp_API __declspec(dllexport)
#else
#define cpp_API __declspec(dllimport)
#endif
extern "C" 
{
cpp_API char* cpp_Version(void); // What should i use better for(void) and what is the meaning char*
cpp_API int cpp_AddUser(void* User, double Acc, double Limit, int* NewId); //example for void* variable and int* variable
cpp_API int cpp_AddModifyBilling(int Act, int Level, wchar_t* BillingCo, wchar_t* Desc, int * BillingId); //example for int * variable
cpp_API int cpp_DeleteBilling(int Act, wchar_t* Code1, wchar_t* Code2, wchar_t* Code3, int Billable, int *CombId); //example for int *variable
cpp_API int cpp_GetUser(int UserId, void** UserInfo); //example for void** variable

...
}

#pragma pack(1) //and is the meaning about this one ??

Question:
1. Whether * (the symbol) that is used in other types of data that have the same meaning and what is the meaning about the position between type and variable?
2. If I want to marshalls to C# data types which data types are more suitable for the type of data that will be in marshall?

Any suggestions and answers would be very helpful
Thank you

Zealkid
  • 11
  • 2
  • You will need to learn what is a pointer in C++ (* is used to declare pointers) – quantdev Jun 04 '14 at 03:12
  • Oh the symbol's name is pointer, ok i got it but how about double pointer (**)?? is this has same meaning??and can i use the pointer in c#?? – Zealkid Jun 04 '14 at 03:27

1 Answers1

1

Single * is a pointer, it's means an address of a variable. Double ** is a pointer which is point to another pointer. Well, this is basic concept of C++. If you want learn more, read a good textbook.

For your question, C# can use pointer. But it will make your program become "unsafe code". Please google "unsafe code" for more information if you never heard that.

Therefore, C# provides IntPtr to access C++ library which using pointer. IntPtr is a type of variable which means "I'm a pointer". It can solves most case of single * pointer. However, you may need the C#'s pointer to solve the double ** pointer. You can refer to this thread for the solution both * and ** pointer.

Community
  • 1
  • 1
J.C
  • 633
  • 1
  • 13
  • 27
  • ok thanks for the reference i am looking for that but the pointer symbol its like null in search engine :( anyway thanks for your answer :) – Zealkid Jun 04 '14 at 04:08
  • Sure, Google does not identify symbols in most case. Use "pointer" and "double pointer" to replace * and ** in your searching keyword. – J.C Jun 04 '14 at 05:13