Jump to content
  • Advertisement
Sign in to follow this  
noatom

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

This topic is 2140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
Guest Hiwas
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!