Compilation error

Official forum for the Chipmunk2D Physics Library.

Compilation error

Postby Hexasoft » Fri May 06, 2016 2:54 pm

Hello,
I'm trying to compile a small code with CP stuff but I get a strange error.

The piece of code is:
Code: Select all
  cpSpace *space = cpSpaceNew();
  if (space == NULL) { return(0); }
  cpSpaceSetGravity(space, cpv(0,0));
 
  cpShape *ground1 = cpSegmentShapeNew(space->staticBody, cpv(0, 0), cpv(RES_WIDTH-1, 0), 0);

I get an error on the cpSegmentShapeNew() line:
Code: Select all
error: dereferencing pointer to incomplete type
   cpShape *ground1 = cpSegmentShapeNew(space->staticBody, cpv(0, 0), cpv(RES_WIDTH-1, 0), 0);
                                             ^

This is compiled on a 64bit latest Ubuntu with gcc, using own-compiled latest Chipmunk. I tried to also include "spSpace.h" (in addition of chipmunk.h) for testing but it lead to duplicated declarations. I don't get any error before this line (compiled with -Wall).
Note: I don't have the chipmunk package from ubuntu installed (as it is an older version).

By the way I was re-using an old code using Chipmunk and it seems that cpShapeSetLayers() function don't exists anymore.

Thanks for any help.

Regards,
--
Hexasoft
Hexasoft
 
Posts: 7
Joined: Wed May 04, 2016 10:51 am

Re: Compilation error

Postby slembcke » Fri May 06, 2016 4:03 pm

In Chipmunk 6, using the getter functions (ex: cpSpaceGetStaticBody()) was recommended. In Chipmunk 7, they are required. The contents are supposed to be private, but you can still access them if you want by importing chipmunk_structs.h.

Was that from some example code that I need to update?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Compilation error

Postby Hexasoft » Sat May 07, 2016 2:16 am

Thanks for your reply, I will check that.

This code was part of an old code of mine that I reused but yes the documentation should be updated as when I checked back the documentation I found exactly the same (that's why I put a question here as my code was confirmed by the doc).
It is in page https://chipmunk-physics.net/release/Ch ... test-Docs/ in the « Hide/Show Hello Chipmunk Example » where we can read cpShape *ground = cpSegmentShapeNew(space->staticBody, cpv(-20, 5), cpv(20, -5), 0); (and maybe in other places).

Thanks.

Regards,
--
Hexasoft
Hexasoft
 
Posts: 7
Joined: Wed May 04, 2016 10:51 am

Re: Compilation error

Postby slembcke » Sat May 07, 2016 7:41 am

Ah. That would explain why I didn't find it when I did a grep search. It's in an HTML file that is heavily marked up.

It's fixed in Git now. I suppose I should do a release build since there are some mild fixes since 7.0.1.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Compilation error

Postby Hexasoft » Sat May 07, 2016 10:14 am

Ok, nice.

BTW it is maybe included in your changes but some few other problems in the documentation:
- several links to HTML anchors are broken (see "See the section on BodyTypes for more information", or "See Post-Step Callbacks for(…)" but they are others).
- link to ChipmunkDemo.c (at least in "Query examples:" from https://chipmunk-physics.net/release/Ch ... mples.html) points to an empty page (→https://code.google.com/archive/p/chipmunk-physics/source#319)

Regards,
--
Hexasoft
Hexasoft
 
Posts: 7
Joined: Wed May 04, 2016 10:51 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 3 guests

cron