Reputation: 5539
Using the vxWorks API symFind() we can get the address of a global variable knowing its name. Is there a way to know the corresponding size of a symbol?
The fact is that the searched symbol could be of any type and I need to find it at runtime. So I basically can't use the sizeof directive.
Upvotes: 3
Views: 714
Reputation: 183290
This is a priori impossible, since when you add a symbol, you never specify its size: the symAdd
function just takes a SYMTAB_ID
, a name, an address, a type ID, and a group ID. Some of the predefined type IDs imply a size (or at least, imply enough information that you could examine the data at the address and infer a size), but other predefined type IDs do not; and even if they all did, the API still wouldn't have any way to know about user-defined types (since it just sees them as opaque integer identifiers).
Upvotes: 2