Page 1 of 1

Compilation error

Posted: Fri May 06, 2016 2:54 pm
by Hexasoft
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

Re: Compilation error

Posted: Fri May 06, 2016 4:03 pm
by slembcke
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?

Re: Compilation error

Posted: Sat May 07, 2016 2:16 am
by Hexasoft
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

Re: Compilation error

Posted: Sat May 07, 2016 7:41 am
by slembcke
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.

Re: Compilation error

Posted: Sat May 07, 2016 10:14 am
by Hexasoft
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/chipm ... source#319)

Regards,
--
Hexasoft