NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
api.h File Reference

NEOGRAPH_API export/import macro for shared-library builds. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Detailed Description

NEOGRAPH_API export/import macro for shared-library builds.

Public class and free-function declarations decorated with NEOGRAPH_API get the right linkage attribute on every supported platform:

  • When building a NeoGraph library (TU sees NEOGRAPH_BUILDING_LIBRARY): __declspec(dllexport) on Windows, visibility("default") on Linux/macOS.
  • When consuming a NeoGraph library (downstream binding / application): __declspec(dllimport) on Windows, no-op elsewhere.
  • Static builds on any platform: empty.

The CMake target machinery sets NEOGRAPH_BUILDING_LIBRARY (a target_compile_definitions PRIVATE on each neograph_* library) and NEOGRAPH_STATIC_BUILD (when BUILD_SHARED_LIBS is OFF). Headers don't need any other glue.

Why a custom macro instead of CMake's generate_export_header? The engine ships several libraries (neograph_core, neograph_async, neograph_llm, ...) that can include each other's public headers. generate_export_header produces a per-library macro; managing four separate XXX_EXPORT ifdefs across the headers gets tangled fast. A single NEOGRAPH_API keyed on whether ANY neograph_* TU is being compiled keeps the source tree clean — at the cost of treating cross-library calls inside the engine as if every public symbol were a same-library call (which they effectively are during the engine's own build).

Definition in file api.h.