Skip to content

[DOCS] C snippets use nonexistent WasmEdge_ModuleInstance, WasmEdge_Result_Error and WasmEdge_ValType_I32 #320

Open

Description

@NopeCharon

Description

Some C snippets in the docs use API names that don't exist in the WasmEdge C API, so they fail to compile when copied:

  1. The "create module instances from plug-ins" snippet declares WasmEdge_ModuleInstance *ModCxt. The type is WasmEdge_ModuleInstanceContext; WasmEdge_ModuleInstance has never existed. This snippet appears in docs/embed/use-case/plugin/c_sdk.md, docs/embed/c/reference/latest.md, the versioned references 0.12.x.md to 0.17.x.md, and upgrade_to_0.12.0.md (with the same copies under i18n/zh).
  2. The "Securing the Plugin" snippets in docs/contribute/plugin/best_practice.md use:
    • WasmEdge_Result_Error. The only predefined results are WasmEdge_Result_Success, WasmEdge_Result_Terminate and WasmEdge_Result_Fail.
    • In[0].Type != WasmEdge_ValType_I32. Since 0.14.0, WasmEdge_ValType is a struct, and the value type is checked with WasmEdge_ValTypeIsI32().

I compiled the snippets with gcc against the 0.18.1 release headers:

error: unknown type name 'WasmEdge_ModuleInstance'; did you mean 'WasmEdge_ModuleInstanceContext'?
error: 'WasmEdge_ValType_I32' undeclared (first use in this function); did you mean 'WasmEdge_ValTypeIsI32'?
error: 'WasmEdge_Result_Error' undeclared (first use in this function); did you mean 'WasmEdge_Result_Fail'?

Screenshots

No response

Additional information

Fix: use WasmEdge_ModuleInstanceContext, WasmEdge_ValTypeIsI32(In[i].Type) and WasmEdge_Result_Fail in these snippets.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions