JaciBrunning / Pathfinder

Cross-Platform, Multi-Use Motion Profiling and Trajectory Generation
MIT License
255 stars 78 forks source link

Add C++ Port #19

Open ryegleason opened 6 years ago

ryegleason commented 6 years ago

A port for C++ allowing users to copy and paste the files into their C++ project and use them instead of having to compile the library separately or deal with compiling C from C++.

JaciBrunning commented 6 years ago

C++ is based upon C, under what premise would Pathfinder not be able to be compiled from C++? It should compile with no issues, since the syntax is the same. If there are issues, this should be addressed in both versions.

ryegleason commented 6 years ago

Not ruling out that I suck at C++, when I try to compile the source using

extern "C" {
#include "pathfinder.h"
}

it fails because there are uncast memory allocations, which are, afaik, allowed in C but not in C++. I added casts mostly, but also changed the header files to only compile as-needed instead of doing everything with pathfinder.h.

JaciBrunning commented 6 years ago

The casting issues sound like something that should be fixed in the C version of the library.

There is nothing necessary about requiring pathfinder.h in the core library, you can include your files as needed. Keep in mind that pathfinder.h already provides an extern "C" {} declaration for all further imports, which is part of the reason it exists.