Loading ...
Sorry, an error occurred while loading the content.

Accessing shape collection in C++

Expand Messages
  • D Henton
    I am using the autotrace API in a C++ application (http://inkulator.sourceforge.net). I am trying to access the spline structures (spline_type,
    Message 1 of 5 , Feb 12, 2005
    • 0 Attachment
      I am using the autotrace API in a C++ application (http://inkulator.sourceforge.net). I am trying to access the spline structures (spline_type, spline_array_list...) in my C++ program, but they appear to have some kind of packing problem. The first data point is accessible, and then the reset are full of garbage. I suspect some kind of incompatibility due to packing/alignment issues.

      My question is this, would anybody here be able to give me a clue as to how to fix this? I think that creating structures on the autotrace side that contain padding might be the way to go, but I haven't a clue as to how to pad, what the alignment is or what. I'm not that much of a C programmer.

      Any help appreciated!!!



      --
      _____________________________________________________________
      Web-based SMS services available at http://www.operamail.com.
      From your mailbox to local or overseas cell phones.

      Powered by Outblaze
    • Masatake YAMATO
      ... The problem is not clear for me. What is the first data ? Autotrace s output modules(e.g. svg, pdf) can write the whole out spline structures witnout
      Message 2 of 5 , Feb 12, 2005
      • 0 Attachment
        > I am using the autotrace API in a C++ application
        > (http://inkulator.sourceforge.net). I am trying to access the spline
        > structures (spline_type, spline_array_list...) in my C++ program, but
        > they appear to have some kind of packing problem. The first data point
        > is accessible, and then the reset are full of garbage. I suspect some
        > kind of incompatibility due to packing/alignment issues.

        The problem is not clear for me. What is "the first data"?
        Autotrace's output modules(e.g. svg, pdf) can write the whole out
        spline structures witnout problem. If the spline structures contains
        garbages, could you explain why the output modules work?
      • James Lehman
        I don t know the specifics of your question, but in general, I understand your issue. This is very common when working with data structures in memory and then
        Message 3 of 5 , Feb 12, 2005
        • 0 Attachment
          I don't know the specifics of your question, but in general, I understand your issue. This is very common when working with data structures in memory and then writing or reading that data to files. There are C/C++ preprocessor directives for this very reason. Typically, on 32 bit machines, data is packed on 4 byte boundaries for speed.
           
          #pragma pack(1) // packs data structures down to 1 byte boundaries.
          #pragma pack() // with no arguments sets it back to its default value.
           
          These directives need to appear before you define your data structures.
           
          #pragma pack(1)
           
          class foo
          {
          public:
              char x;
              short y;
              int z;
              long long w;
          };
           
          #pragma pack()
           
          Now foo will take up exactly 15 bytes in memory; 1 + 2 + 4 + 8.
          And you can rely on the fact that this data is in order with no junk bytes.
          You can even copy 15 bytes of data into a pointer to foo.
           
          I hope this helps!
           
          Good luck.
           
           
          Take care.   James.   :o)
           
           
          ----- Original Message -----
          From: D Henton
          Sent: Saturday, February 12, 2005 7:49 AM
          Subject: [AutoTrace] Accessing shape collection in C++



          I am using the autotrace API in a C++ application (http://inkulator.sourceforge.net). I am trying to access the spline structures (spline_type, spline_array_list...) in my C++ program, but they appear to have some kind of packing problem. The first data point is accessible, and then the reset are full of garbage. I suspect some kind of incompatibility due to packing/alignment issues.

          My question is this, would anybody here be able to give me a clue as to how to fix this? I think that creating structures on the autotrace side that contain padding might be the way to go, but I haven't a clue as to how to pad, what the alignment is or what. I'm not that much of a C programmer.

          Any help appreciated!!!



          --
          _____________________________________________________________
          Web-based SMS services available at http://www.operamail.com.
          From your mailbox to local or overseas cell phones.

          Powered by Outblaze

        • Dan Mills
          ... These are Microsoft specific, and do not work on the GNU compilers where structure attribute tags are used instead. I suspect that the real problem is a
          Message 4 of 5 , Feb 13, 2005
          • 0 Attachment
            On Saturday 12 February 2005 18:03, James Lehman wrote:
            > I don't know the specifics of your question, but in general, I understand
            > your issue. This is very common when working with data structures in memory
            > and then writing or reading that data to files. There are C/C++
            > preprocessor directives for this very reason. Typically, on 32 bit
            > machines, data is packed on 4 byte boundaries for speed.
            >
            > #pragma pack(1) // packs data structures down to 1 byte boundaries.
            > #pragma pack() // with no arguments sets it back to its default value.
            >


            These are Microsoft specific, and do not work on the GNU compilers where
            structure attribute tags are used instead.

            I suspect that the real problem is a missing

            extern "C" {

            <Autotrace headers go here>

            }

            in the C++ code?
            This switches off name mangling for references to the appropriate headers and
            may also have other more subtle effects.

            Regards, Dan.
          • D Henton
            Indeed there is a extern C around the structure definitions in autotrace.h and it is placed into the code when preprocessor __cplusplus is defined.
            Message 5 of 5 , Feb 13, 2005
            • 0 Attachment
              Indeed there is a "extern C" around the structure definitions in autotrace.h and it is placed into the code when preprocessor "__cplusplus" is defined.

              Supposedly, I've done that, but I need to confirm that it is actually set.



              ----- Original Message -----
              From: "Dan Mills" <dmills@...>
              To: autotrace@yahoogroups.com
              Subject: Re: [AutoTrace] Accessing shape collection in C++
              Date: Sun, 13 Feb 2005 12:38:37 +0000



              <html><body>



              <tt>
              On Saturday 12 February 2005 18:03, James Lehman wrote:<BR>
              > I don't know the specifics of your question, but in general, I understand<BR>
              > your issue. This is very common when working with data structures in memory<BR>
              > and then writing or reading that data to files. There are C/C++<BR>
              > preprocessor directives for this very reason. Typically, on 32 bit<BR>
              > machines, data is packed on 4 byte boundaries for speed.<BR>
              ><BR>
              > #pragma pack(1) // packs data structures down to 1 byte boundaries.<BR>
              > #pragma pack() // with no arguments sets it back to its default value.<BR>
              ><BR>
              <BR>
              <BR>
              These are Microsoft specific, and do not work on the GNU compilers where <BR>
              structure attribute tags are used instead.<BR>
              <BR>
              I suspect that the real problem is a missing <BR>
              <BR>
              extern "C" {<BR>
              <BR>
              <Autotrace headers go here><BR>
              <BR>
              }<BR>
              <BR>
              in the C++ code? <BR>
              This switches off name mangling for references to the appropriate headers and <BR>
              may also have other more subtle effects. <BR>
              <BR>
              Regards, Dan.<BR>
              </tt>


              <br>

              <!-- |**|begin egp html banner|**| -->

              <table border=0 cellspacing=0 cellpadding=2>
              <tr bgcolor=#FFFFCC>
              <td align=center><font size="-1" color=#003399><b>Yahoo! Groups Sponsor</b></font></td>
              </tr>
              <tr bgcolor=#FFFFFF>
              <td align=center width=470><table border="0" cellpadding="0" cellspacing="0"><tr><td align="center"><font face="arial" size="-2">ADVERTISEMENT</font><br><iframe src="http://view.atdmt.com/NFX/iview/yhxxxnfx0020000014nfx/direct/01/&time=1108298320716056?click=http://us.ard.yahoo.com/SIG=1298tveek/M=298184.6018725.7038619.3001176/D=groups/S=1705007295:HM/EXP=1108384720/A=2532114/R=0/*" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" width="300" height="250">
              <script language="JavaScript" type="text/javascript">
              document.write('<a href="http://us.ard.yahoo.com/SIG=1298tveek/M=298184.6018725.7038619.3001176/D=groups/S=1705007295:HM/EXP=1108384720/A=2532114/R=1/SIG=12kk2k7q5/*http://clk.atdmt.com/NFX/go/yhxxxnfx0020000014nfx/direct/01/&time=1108298320716056" target="_blank"><img src="http://view.atdmt.com/NFX/view/yhxxxnfx0020000014nfx/direct/01/&time=1108298320716056"/></a>');
              </script><noscript><a href="http://us.ard.yahoo.com/SIG=1298tveek/M=298184.6018725.7038619.3001176/D=groups/S=1705007295:HM/EXP=1108384720/A=2532114/R=2/SIG=12kk2k7q5/*http://clk.atdmt.com/NFX/go/yhxxxnfx0020000014nfx/direct/01/&time=1108298320716056" target="_blank"><img border="0" src="http://view.atdmt.com/NFX/view/yhxxxnfx0020000014nfx/direct/01/&time=1108298320716056" /></a></noscript></iframe></td></tr></table></td>
              </tr>
              <tr><td><img alt="" width=1 height=1 src="http://us.adserver.yahoo.com/l?M=298184.6018725.7038619.3001176/D=groups/S=:HM/A=2532114/rand=579596149"></td></tr>
              </table>

              <!-- |**|end egp html banner|**| -->



              <!-- |**|begin egp html banner|**| -->

              <br>
              <tt><hr width="500">
              <b>Yahoo! Groups Links</b><br>
              <ul>
              <li>To visit your group on the web, go to:<br><a href="http://groups.yahoo.com/group/autotrace/">http://groups.yahoo.com/group/autotrace/</a><br>
              <li>To unsubscribe from this group, send an email to:<br><a href="mailto:autotrace-unsubscribe@yahoogroups.com?subject=Unsubscribe">autotrace-unsubscribe@yahoogroups.com</a><br>
              <li>Your use of Yahoo! Groups is subject to the <a href="http://docs.yahoo.com/info/terms/">Yahoo! Terms of Service</a>.
              </ul>
              </tt>
              </br>

              <!-- |**|end egp html banner|**| -->


              </body></html>







              Whatever you are looking for is where you find it

              --
              _____________________________________________________________
              Web-based SMS services available at http://www.operamail.com
              From your mailbox to local or overseas cell phones.

              Powered by Outblaze
            Your message has been successfully submitted and would be delivered to recipients shortly.