You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should the mmap, munmap, etc. functions in mman.h be inlined to avoid the ODR? I've been including the annoylib.h headers in several *.cpp files that are to be used to create a single shared library (in an R package via RcppAnnoy, see https://github.com/LTLA/BiocNeighbors) - this works fine, except on Windows where linking fails due to multiple definitions of the mm* functions. This seems like a standard case for requiring inlineing in a header-only library, though I don't have a Windows machine available to confirm it's a fix.
The text was updated successfully, but these errors were encountered:
Ah, sorry - One Definition Rule. The header guard only protects against multiple includes in a single translation unit (i.e., each *.o, in my case) but it doesn't protect against multiple definitions upon linking different units into a single library, which is the problem here. I'm no expert on this, but inlineing the relevant functions seems to help, presumably by forcing the functions to be be defined locally in each unit that includes the header file.
Should the
mmap
,munmap
, etc. functions inmman.h
beinline
d to avoid the ODR? I've been including theannoylib.h
headers in several*.cpp
files that are to be used to create a single shared library (in an R package via RcppAnnoy, see https://github.com/LTLA/BiocNeighbors) - this works fine, except on Windows where linking fails due to multiple definitions of themm*
functions. This seems like a standard case for requiringinline
ing in a header-only library, though I don't have a Windows machine available to confirm it's a fix.The text was updated successfully, but these errors were encountered: