uber / h3

Hexagonal hierarchical geospatial indexing system
https://h3geo.org
Apache License 2.0
4.83k stars 459 forks source link

Is h3-c perfectly compatible with c plus plus? #761

Closed GitBenjamin closed 1 year ago

GitBenjamin commented 1 year ago

I wanted to integrate H3 into my project to experiment, but I was worried that it wouldn't work well with cpp. @nrabinowitz @isaacbrodsky

isaacbrodsky commented 1 year ago

The C library itself should be compatible with C++. We already use extern "C" blocks for the exported functions (https://github.com/uber/h3/blob/master/src/h3lib/include/h3api.h.in#L62) and so the H3 header file should work as-is.

If you copy the H3 source code in and run it through a C++ compiler I would expect it will work. We are not depending on very modern versions of C. The results will depend on the specific C++ compiler you use and how it treats C source files. Please let us know if there's a compiler out there that can accept C but has issues with H3.

GitBenjamin commented 1 year ago

Thank you! I tried to compile with h3Config.cmake, but it didn't work. I can't find h3_INCLUDE_DIRS and h3_LIBRARIES.