SebastianRiedel / bingham

Bingham Statistics Library (BSL)
BSD 3-Clause "New" or "Revised" License
42 stars 21 forks source link

(Feature request) Porting to OS X #6

Open wfbradley opened 9 years ago

wfbradley commented 9 years ago

Dear Sebastian,

I was interested in running this code on my Mac (running OS X 10.9.5). The only compilation issue was that on Macs, the native C compiler is clang (gcc redirects to it), and clang handles function inlining a little differently than gcc. For a description of the issue, see: http://clang.llvm.org/compatibility.html#inline

Anyway, the fix here is to delete "inline" from (most of) the inlined functions. There are two static inline functions in util.c that can remain: static inline int meshgraph_add_vertex_neighbor(meshgraph_t g, int i, int vertex, int edge) static inline int meshgraph_add_edge_neighbor(meshgraph_t g, int i, int vertex, int face)

With this change, everything compiles.

I wanted to ask you if you would consider making an option for automatically dropping the inlining (I guess through make install?) when compiling on a Mac; it would be great if people like me could use this code out-of-the-box.

Thanks, Bill

SebastianRiedel commented 9 years ago

Hi Bill,

I have a tight schedule at work at the moment, so I can't fix this in the near future. Also, I don't have a Mac platform available to test it. However, you are more then welcome to provide a pull request.

I guess it could be as easy as 1) detecting the Mac platform in the Makefile, 2) add a -D OSX flag to the CCFLAGS (compile flags) in case we're on a Mac and 3) switch the inline functions to a non-inline version if the define is set via #ifdef-s (that's what you did manually now, right?).

Best, Sebastian

wfbradley commented 9 years ago

Dear Sebastian,

Sure, I'll try to clean up my code and send you a pull request. (After I learn how to make a pull request :) ).

Bill