Sign in to follow this  

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

Recommended Posts

Hiwas    5807
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this