Skip to content

Fix errors and warnings when compiling with C++26. - #704

Open
jteuber wants to merge 1 commit into
ChaiScript:developfrom
jteuber:module_and_cpp26_fixes
Open

jteuber wants to merge 1 commit into
ChaiScript:developfrom
jteuber:module_and_cpp26_fixes

Conversation

@jteuber

@jteuber jteuber commented Sep 23, 2026

Copy link
Copy Markdown

I'm working on a project using clang with C++26 (or at least what's already implemented in clang) and modules. When compiling my project without the changes in this PR I'm getting the following errors and warnings:

/usr/bin/../include/c++/v1/__memory/unique_ptr.h:72:19: error: invalid application of 'sizeof' to an incomplete type 'chaiscript::AST_Node'
   72 |     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
      |                   ^~~~~~~~~~~
/usr/bin/../include/c++/v1/__memory/unique_ptr.h:288:7: note: in instantiation of member function 'std::default_delete<chaiscript::AST_Node>::operator()' requested here
  288 |       __deleter_(__tmp);


/home/jay/Projects/deps/include/chaiscript/dispatchkit/dispatchkit.hpp:846:30: error: variable has incomplete type 'std::exception_ptr'
  846 |           std::exception_ptr except;


/home/jay/Projects/deps/include/chaiscript/dispatchkit/handle_return.hpp:35:72: warning: 'is_trivial_v<bool>' is deprecated: Consider using is_trivially_copyable_v<T> && is_trivially_default_constructible_v<T> instead. [-Wdeprecated-declarations]
   35 |         template<typename T, typename = typename std::enable_if_t<std::is_trivial_v<typename std::decay_t<T>>>>

I'm using the following module wrapper in my project:

module;

#include <chaiscript/chaiscript.hpp>
#include <chaiscript/extras/math.hpp>
#include <chaiscript/extras/string_methods.hpp>

export module wrapper.chaiscript;

// Re-export all ChaiScript symbols
export namespace chaiscript {
using chaiscript::AST_Node;
using chaiscript::AST_Node_Type;
using chaiscript::AST_NodePtr;
using chaiscript::boxed_cast;
using chaiscript::Boxed_Number;
using chaiscript::Boxed_Value;
using chaiscript::ChaiScript;
using chaiscript::constructor;
using chaiscript::fun;
using chaiscript::Module;
using chaiscript::ModulePtr;
using chaiscript::user_type;
using chaiscript::var;

// Parsing without evaluating, for static validation of shipped content scripts.
namespace parser {
using chaiscript::parser::ChaiScript_Parser_Base;
}

// Dynamic_Object: a script `class` instance. Consumed by world::facilities::ScriptValueCodec's
// nominal check (Cluster Map Session 3) — production code, not a test.
namespace dispatch {
using chaiscript::dispatch::Dynamic_Object;
}

namespace bootstrap::standard_library {
using chaiscript::bootstrap::standard_library::vector_type;
}

// Exception types
namespace exception {
using chaiscript::exception::bad_boxed_cast;
using chaiscript::exception::eval_error;
} // namespace exception

namespace extras {
namespace math {
using chaiscript::extras::math::bootstrap;
}
namespace string_methods {
using chaiscript::extras::string_methods::bootstrap;
}
} // namespace extras

} // namespace chaiscript

// Explicit template instantiations for ChaiScript to resolve linker errors
// ChaiScript is a header-only library with template static members that need
// explicit instantiation when used with C++20 modules.
template class chaiscript::parser::ChaiScript_Parser<
    chaiscript::eval::Tracer<chaiscript::eval::Noop_Tracer_Detail>,
    chaiscript::optimizer::Optimizer<chaiscript::optimizer::Partial_Fold,
                                     chaiscript::optimizer::Unused_Return,
                                     chaiscript::optimizer::Constant_Fold,
                                     chaiscript::optimizer::If,
                                     chaiscript::optimizer::Return,
                                     chaiscript::optimizer::Dead_Code,
                                     chaiscript::optimizer::Block,
                                     chaiscript::optimizer::For_Loop,
                                     chaiscript::optimizer::Assign_Decl>,
    512>;

I'm aware that the changes in this PR are specific to my setup and need generalizing before merging. You can also view it as an extended issue ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants