diff --git a/examples/context-engineering/context-engineering.cpp b/examples/context-engineering/context-engineering.cpp index 0390d32..9bd6447 100644 --- a/examples/context-engineering/context-engineering.cpp +++ b/examples/context-engineering/context-engineering.cpp @@ -8,6 +8,7 @@ #include "llama.h" #include "logging_callback.h" #include "model.h" +#include "platform_compat.h" #include "tool.h" #include #include @@ -15,7 +16,6 @@ #include #include #include -#include static constexpr size_t DEFAULT_MAX_TOOL_CALLS = 1; diff --git a/examples/memory/memory.cpp b/examples/memory/memory.cpp index 7e14aa9..3fe4f0c 100644 --- a/examples/memory/memory.cpp +++ b/examples/memory/memory.cpp @@ -15,7 +15,6 @@ #include #include #include -#include using agent_cpp::json; diff --git a/examples/multi-agent/multi-agent.cpp b/examples/multi-agent/multi-agent.cpp index f4e5d44..6d10b97 100644 --- a/examples/multi-agent/multi-agent.cpp +++ b/examples/multi-agent/multi-agent.cpp @@ -15,7 +15,6 @@ #include #include #include -#include using agent_cpp::json; diff --git a/examples/shared/chat_loop.h b/examples/shared/chat_loop.h index 3d090cc..5f08d6d 100644 --- a/examples/shared/chat_loop.h +++ b/examples/shared/chat_loop.h @@ -2,10 +2,10 @@ #include "agent.h" #include "chat.h" +#include "platform_compat.h" #include #include #include -#include #include // Run an interactive chat loop with the given agent. diff --git a/examples/shared/logging_callback.h b/examples/shared/logging_callback.h index 72770a1..eeb79bb 100644 --- a/examples/shared/logging_callback.h +++ b/examples/shared/logging_callback.h @@ -1,10 +1,10 @@ #pragma once #include "callbacks.h" +#include "platform_compat.h" #include "tool_result.h" #include #include -#include // Logging callback to display tool execution information. // Shared across examples to provide consistent tool call logging. diff --git a/examples/shared/platform_compat.h b/examples/shared/platform_compat.h new file mode 100644 index 0000000..5aadf7a --- /dev/null +++ b/examples/shared/platform_compat.h @@ -0,0 +1,16 @@ +#pragma once + +// Small compatibility shim so the examples build with MSVC, which does not +// ship and prefixes the POSIX names with an underscore. +// Shared across examples to avoid repeating the same #ifdef block. + +#ifdef _WIN32 +#include + +#define isatty _isatty +#define popen _popen +#define pclose _pclose + +#else +#include +#endif // _WIN32 diff --git a/examples/shell/shell.cpp b/examples/shell/shell.cpp index d66d06b..8a7982b 100644 --- a/examples/shell/shell.cpp +++ b/examples/shell/shell.cpp @@ -6,6 +6,7 @@ #include "error_recovery_callback.h" #include "llama.h" #include "model.h" +#include "platform_compat.h" #include "tool.h" #include @@ -15,7 +16,6 @@ #include #include #include -#include using agent_cpp::json; using agent_cpp::ToolExecutionSkipped; diff --git a/examples/tracing/tracing.cpp b/examples/tracing/tracing.cpp index 9e79dd7..839d4d8 100644 --- a/examples/tracing/tracing.cpp +++ b/examples/tracing/tracing.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include namespace trace_api = opentelemetry::trace;