comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » C Alignment/IDL structures
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: C Alignment/IDL structures [message #43159 is a reply to message #43098] Mon, 21 March 2005 08:56 Go to previous messageGo to previous message
joey is currently offline  joey
Messages: 5
Registered: March 2005
Junior Member
Randall Skelton <randall.skelton@gmail.com> wrote:
> I'm not sure I completely understand what you are doing... can you post
> a snipit of code? I trust that you are passing back an unnamed

Here's my code that does the IDL/C interaction. I have a vector (_dataIDL)
which has all the values I want into IDL within it as a malloc'ed sets of
memory.

// Copy the real data

unsigned long pos = 0;
unsigned char *myStructureThatLooksLikeTags = malloc (_totalSpaceNeeded
* _dataIDL.size ());
for (unsigned int i = 0; i < _dataIDL.size (); i++) {
memcpy (&(myStructureThatLooksLikeTags [pos]), _dataIDL [i],
_totalSpaceNeeded);
pos += _totalSpaceNeeded;
}

char idl_struct_name [100];
sprintf (idl_struct_name, "%s_K%ld_V%d", dbVirtualName (data_key),
data_key, version);

void *idl_struct = IDL_MakeStruct (idl_struct_name, tags);
IDL_LONG dims;
dims = _dataIDL.size (); // number of elment in the array of structures
IDL_VPTR ivReturn = IDL_ImportArray (1, &dims, IDL_TYP_STRUCT,
myStructureThatLooksLikeTags,
cleanUpIDL, idl_struct);

> In general, when I have to pass C structures from existing code back to
> IDL I do it by creating a shadow structure (in C) that uses all the
> defined IDL types and copying the data. You really cannot rely on
> generic C variables having the same size as thier IDL counterparts
> (take a look at the definition of IDL_ALLTYPES in idl_export.h).

Ok, this probably answers my question. I was hoping I could create an array
of structs, but this is maybe not so memory efficient so I might try to
create one structure with multiple arrays.

Joey
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Compile or not compile?
Next Topic: Re: Converting INT to STRING out of space...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 21:24:56 PDT 2025

Total time taken to generate the page: 0.40148 seconds