Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

How do i use sizeof when creating a library?(visual studio)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 noatom   Members   

925
Like
0Likes
Like

Posted 10 September 2013 - 05:23 PM

So I recently ran into this problem.How does one get the size of a certain type of object when creating a library?



#2 Brother Bob   Moderators   

10276
Like
4Likes
Like

Posted 10 September 2013 - 05:38 PM

Can you explain your problem more than just referring to it as "this" problem? Using the sizeof operator on a type is no different in a library than anywhere else.



#3 AllEightUp   Moderators   

5763
Like
4Likes
Like

Posted 10 September 2013 - 08:46 PM

I "suspect" the intention is to do something like a plugin system. I.e. you have a class in a library derived from an interface which can be used via a factory. If you want to store such an object in a pool though, you need to know the size of the object in memory which you can't do since you don't know diddly about the runtime linked classes. If this is *not* correct, ignore the following:

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.

#4 noatom   Members   

925
Like
0Likes
Like

Posted 11 September 2013 - 01:35 AM

AllEigthUp,that was what i was asking,thanks.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.