So I recently ran into this problem.How does one get the size of a certain type of object when creating a library?
How do i use sizeof when creating a library?(visual studio),
Moderators - Reputation: 5483
Posted 10 September 2013 - 08:46 PM
Basically, you can't do it. That is not to say you can not get the same effect though. You have to sidestep the issue and basically implement a static function which can be called to get the sizeof. Assuming you use a centralized factory, when you register the type, pass in the 'sizeof' at that time. Instead of doing "sizeof( something )", you now use "factory->SizeOf( something )". How you refer to 'something' is up to you, Id/GUID etc. There are many ways to work around this in a dynamic link environment, if you don't have a centralized factory, you can always use a per dll function which includes all the sizes so you can ask the actual Dll in that case.
Mostly though, Brother Bob has the correct question. I'm just making a best guess assumption based on the reasons I've needed such information in the past.