typedef struct TestStruct
{
const char * m_device;
unsigned m_value;
}
What size is m_device type;
What does const mean?
What size is m_value type?
--
Regards,
Ma�ko
It is the size of a pointer to char (sizeof(char*)). Probably it will
be 4 or 8 bytes.
> What does const mean?
It means that the character(s) that m_device refers to can not be
changed by the program.
>
> What size is m_value type?
It is sizeof(unsigned int) bytes. Probably 4.
>
> --
> Regards,
> Maæko
Bart v Ingen Schenau
> It is the size of a pointer to char (sizeof(char*)). Probably it will
> be 4 or 8 bytes.
So on win32 systems it will be 4 bytes?
This code is run under VC++ 2005.
> What does const mean?
It means that the character(s) that m_device refers to can not be
changed by the program.
>
> What size is m_value type?
> It is sizeof(unsigned int) bytes. Probably 4.
Thanx :)
>
> --
> Regards,
> Ma�ko
Bart v Ingen Schenau
>> I've got following struct in C++
>>
>> typedef struct TestStruct
>> {
>> const char * m_device;
>> unsigned m_value;
>>
>> }
>>
>> What size is m_device type;
>
>> It is the size of a pointer to char (sizeof(char*)). Probably it will
>> be 4 or 8 bytes.
>
> So on win32 systems it will be 4 bytes?
> This code is run under VC++ 2005.
Yes, but why does that matter to you?
I've got unmanaged C++ dll that exports some functions, classes and
callbacks.
I want to use that DLL in C# under VS 2008.
Some of the exported functions returns complex types as instances of
unmanaged classes - pointers in memory.
To convert pointer to managed structers in C# i have to define managed
equivalent classes (or structs).
My next question:
typedef enum MyEnum
{
enum1,
enum2
}
what is the size of variable of type MyEnum in C++?
sizeof(int).
If your questions require answers that are windows specific, you might
be better of asking on a windows group.
--
Ian Collins
Write a small C++ program that answers all your such questions in
style:
std::cout << "sizeof( MyEnum ) is:"
<< sizeof( MyEnum )
<< std::endl;
No, the implementation can pick almost any integral type that can represent
all the enumerators and their OR. So here 1 would be good. Compilers may
have switch to force enums to a bigger size like a whole int.
It might be that if your asking these very basic questions that your not
yet qualified to do this task. In fact, your question might not get you
the answer you need.
Ruben