<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[why my interface is sealed in maxon::Result?]]></title><description><![CDATA[<p dir="auto">Hi guys,<br />
I'm following the maxonsdk.module listed in <a href="https://developers.maxon.net/docs/cpp/25_113/page_maxonapi_sdk.html#page_maxonapi_sdk_structure_example" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>. Which declare a <code>SimpleNumberInterface</code> and implement it with <code>SimpleNumberImpl</code>. I mimic the steps as follow</p>
<ol start="0">
<li>projectdefinition.txt</li>
</ol>
<pre><code>Platform=Win64;OSX;Linux
Type=DLL
APIS=core.framework
stylecheck=false
ModuleId=net.yu.myp
</code></pre>
<ol>
<li>myifc.h</li>
</ol>
<pre><code>#pragma once
#include "maxon/object.h"
class MyIfc : MAXON_INTERFACE_BASES(maxon::ObjectInterface) {
MAXON_INTERFACE(MyIfc,MAXON_REFERENCE_NORMAL,"net.yu.interface.myifc");
public:
  MAXON_METHOD void Hello();
};
#include "myifc1.hxx"
MAXON_DECLARATION(maxon::Class&lt;MyIfcRef&gt;, MyIfcDecl, "net.yu.myifcdecl");
#include "myifc2.hxx"
</code></pre>
<ol start="2">
<li>myifc.cpp</li>
</ol>
<pre><code>#include "myifc.h"
class MyIfcImpl : public maxon::Component&lt;MyIfcImpl,MyIfc&gt; {
   MAXON_COMPONENT();
public:
  MAXON_METHOD void Hello() {
  }
};
MAXON_COMPONENT_CLASS_REGISTER(MyIfcImpl, MyIfcDecl);
</code></pre>
<ol start="3">
<li>main.cpp</li>
</ol>
<pre><code>#include "myifc.h"
extern "C"
__declspec(dllexport)
int c4d_main(int action, void* p1, void* p2, void* p3) {
  MyIfcRef ifc = MyIfcDecl().Create();   // A
  return 1;
}
</code></pre>
<p dir="auto">At line A , I got the following error</p>
<pre><code>error C2440: 'initializing': cannot convert from 'maxon::Result&lt;MyIfcRef&gt;' to 'MyIfcRef'
</code></pre>
<p dir="auto">How does this happen? Many thanks!</p>
]]></description><link>http://developers.maxon.net/forum//topic/15583/why-my-interface-is-sealed-in-maxon-result</link><generator>RSS for Node</generator><lastBuildDate>Sun, 15 Mar 2026 22:57:03 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum//topic/15583.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 02 Jul 2024 15:29:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to why my interface is sealed in maxon::Result? on Tue, 02 Jul 2024 16:37:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ferdinand">@<bdi>ferdinand</bdi></a> cool. this really helpful!</p>
]]></description><link>http://developers.maxon.net/forum//post/74534</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/74534</guid><dc:creator><![CDATA[yushang]]></dc:creator><pubDate>Tue, 02 Jul 2024 16:37:52 GMT</pubDate></item><item><title><![CDATA[Reply to why my interface is sealed in maxon::Result? on Tue, 02 Jul 2024 16:05:17 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/yushang">@<bdi>yushang</bdi></a>,</p>
<p dir="auto">thank you for reaching out to us. Please have a look at our <a href="https://developers.maxon.net/docs/cpp/2024_4_0/page_maxonapi_error_overview.html" target="_blank" rel="noopener noreferrer nofollow ugc">Error System</a> documentation. You are missing an <code>iferr_return</code> and an error scope in your code.</p>
<pre><code class="language-cpp">int c4d_main(int action, void* p1, void* p2, void* p3) 
{
  // Errors imply being propagated upwards in a call chain. When we want to terminate such chain,
  // i.e., have this function return `int` (you should use Int32 as int is ambiguous) instead of
  // `maxon::Result&lt;maxon::Int32&gt;` we can use a custom error handler to handle errors being thrown.
  // When the return type is `maxon::Result&lt;T&gt;` we can just use an `iferr_scope;` instead.
  iferr_scope_handler
  {
      DebugOutput("c4d_main failed with '@'", err);
      return 0;
  };

  // Create methods return a `maxon::Result&lt;T&gt;` object, i.e., either the value or the error. The
  // `iferr_return` keyword will unpack that error for us.
  MyIfcRef ifc = MyIfcDecl().Create() iferr_return;

  // Technically possible, but bad code:
  maxon::Result&lt;MyIfcRef&gt; result = MyIfcDecl().Create();

  // Can make sense in some cases, but should be generally avoided:
  MyIfcRef ifc = MyIfcDecl().Create() iferr_ignore("We don't care about the error here."_s);

  // Finally, there is a special form of branching that allows to handle errors in a more detailed way:
  ifnoerr (MyIfcRef ifc = MyIfcDecl().Create())
  {
    // Runs when the creation was successful.
  }
  
  iferr (MyIfcRef ifc = MyIfcDecl().Create())
  {
    // Would run when the creation failed.
  }

  return 1;
}
</code></pre>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum//post/74533</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/74533</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Tue, 02 Jul 2024 16:05:17 GMT</pubDate></item></channel></rss>