<br><br><div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">#define BIGINT 1<br>#define DOUBLE 2
<br>#define STRING 4<br>#define ARRAY 8<br>#define INITIALISED 16<br><br>struct sdescript<br>{<br> char * sptr; // pointer to string<br> int salloc; // allocated space for string<br> int slength; // actual length of string - always <= salloc
<br>};<br><br>union varval {<br> int *bi; // BIGINT<br> double *df; // DOUBLE<br> sdescript *sd; // STRING<br>};<br><br>struct variable { // <br> union varval value; //<br> char * varname;<br>
int varlength;<br> char bitflags;<br>};</blockquote><div><br>and <br><br> variable v;<br> *<a href="http://v.value.bi">v.value.bi</a> = 10;<br> v.varname = "@%";<br> v.bitflags = BIGINT;<br> *MOC = v;
<br><br>where MOC is declared as void * gives <br><br>bb1fun.cc:183: error: 'void*' is not a pointer-to-object type<br>183 is the *MOC line.<br><br>Your input is deeply appreciated.<br><br>Cheers Dominic<br></div>
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">What you haven't told us is if your C++ program structures need to<br>*exactly* match the assembler structures
</blockquote><div><br>No. <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>So, actual data in the structure could be represented by something
<br>like:<br><br>struct s<br>{<br> void* a,<br> int16_t b,<br> int16_t c<br>};<br><br>struct record<br>{<br> union u1<br> {<br> int64_t* a,
<br> double* b,<br> s* c<br> };<br><br> union u2<br> {<br> uint64_t a,<br> s b<br> };<br><br> ...<br>};<br><br><br>While this is compact and efficient, it's also a horror from a C++<br>
programmer's perspective. </blockquote><div><br>Yes <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">C++ provides mechanisms in the Standard
<br>Library to do lists,
e.g. std::list and std::vector. These templated<br>containers should, with compiler optimisations turned on, be just as<br>time- and space-efficient as your assembly.<br><br>Consider, C++ lets you code from a higher level perspective, so rather
<br>than show us the exact structure, tell us what you want the code to<br>/do/, and what information needs to be represented. There's sure to<br>be a clean and efficient way of representing it.<br><br>Also note: pointers are /not/ 32 bits. They might be on i386, but
<br>they are not on amd64, and on other architectures, even 32-bit ones,<br>they may be greater than 32 bits (e.g. function pointers).</blockquote><div><br><br>Good point. <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
A pointer<br>is a pointer, and has an architecture-specific size which might even<br>
change depending on what you are pointing to; you can't assume it's 32<br>bits, ever. A C or C++ compiler will always handle this for you.<br><br><br>Regards,<br>Roger<br><br>_______________________________________________
<br>York mailing list
<br><a href="mailto:York@lists.lug.org.uk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">York@lists.lug.org.uk</a><br><a href="https://mailman.lug.org.uk/mailman/listinfo/york" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
https://mailman.lug.org.uk/mailman/listinfo/york</a><br><br><br></blockquote></div><br>