问题
I've started by using reference counting in my library I'm making. It's a pretty decent solution and the increments and decrements don't waste many resources as some people wrongly seem to think. Also the slight extra memory for reference counts is negligible.
But apparently tracing garbage collection is so good that it is better than using malloc/free. I'm not sure if this is true so I'd like to try it out (Back-end optimisations by freeing multiple objects at once?). Also GC would make my library easier to use, as calling retain/release functions is not needed.
Edit: The problem is that gc/gc.h includes itself infinitely. This makes no sense...
Thanks.
回答1:
The question is rather vague. do you want to know how to use libgc in general or do you want to know how to get it working on mac OS X? if later is the case then I recommend using Homebrew. It has a pretty decent formula for libgc. just use the command:
brew install libgc
this will install the library in /usr/local/Cellar/libgc/7.6.0
depending on the latest version available in HomeBrew formula.
the confusion you have regarding gc.h referring to itself infinitively is actually not true. because there is another gc.h in the gc subfolder which the first gc.h is including. I have no idea why they have designed it like this though!
来源:https://stackoverflow.com/questions/10678440/installing-libgc-on-osx-boehms-garbage-collector