ANARI-SDK icon indicating copy to clipboard operation
ANARI-SDK copied to clipboard

Need to move anariGetObjectFeatures definition to the API.cpp implementation file

Open griffin28 opened this issue 2 years ago • 3 comments

Need to move the anariGetObjectFeatures and anariGetInstanceFeatures definitions from the header file (anari_feature_utility.h) to the appropriate implementation file (API.cpp??). Having the definitions in the header file causes a multiple definition error when trying to #include <anari/anari_cpp.hpp> as the definitions will appear in multiple places and the linker doesn't like it.

griffin28 avatar Aug 25 '22 23:08 griffin28

I guess so, for the moment they use a STB style ANARI_FEATURE_UTILITY_IMPL macro to place the defininitions. As long as only one cpp file defines that before including it, it should be fine. I guess the other option would be to just make the functions static.

I'm not sure if "hardwiring" it into the sdk is the correct path. The utility to generate this helper is intentionally written so you could create a custom one with additional (vendor or extension provided) features in it.

progschj avatar Aug 26 '22 01:08 progschj

It doesn't need to go in the SDK, however the current setup doesn't work when ANARI_FEATURE_UTILITY_IMPL is defined in a header file. Making them static functions may be the best solution. In the words of Jakob it just seems weird to have to define ANARI_FEATURE_UTILITY_IMPL first in order to get the list of features from a device when, presumably, all front-ends will need to do this considering the direction the spec is going.

griffin28 avatar Aug 26 '22 02:08 griffin28

Workaround: I created my own GetAnariDeviceFeatures method that returns an anari::Features object that gets updated after processing a list of feature strings returned by anariGetObjectInfo.

griffin28 avatar Aug 30 '22 22:08 griffin28

Closing this as the STB-style usage is the current intention and alternatives introduce link dependencies we want to avoid. Applications should only define ANARI_FEATURE_UTILITY_IMPL in a single .cpp translation unit to ensure a single definition.

jeffamstutz avatar Mar 15 '24 15:03 jeffamstutz