user48730: My sketch contains 2 .h files. one defines
on 1st .h file:
#define JSON_SIZE_IOT 400
#define JSON_SIZE_SKETCH 300
StaticJsonDocument<JSON_SIZE_IOT> paramJSON;
StaticJsonDocument<JSON_SIZE_SKETCH> sketchJSON;

and other need to define paramJSON and sketchJSON as extern
on 2nd .h file:
extern JsonDocument paramJSON;
extern JsonDocument paramJSON;

but I get this error:
error: conflicting declaration 'ArduinoJson6172_91::StaticJsonDocument<400u> paramJSON'
 StaticJsonDocument<JSON_SIZE_IOT> paramJSON;

....
: previous declaration as 'ArduinoJson6172_91::JsonDocument paramJSON'
 extern JsonDocument paramJSON;


user4143: For an extern the whole definition has to match the "master" definition.
So if you have:
StaticJsonDocument<JSON_SIZE_IOT> paramJSON;

then you extern has to be:
extern StaticJsonDocument<JSON_SIZE_IOT> paramJSON;

Of course you have to make sure your JSON_SIZE_IOT is the same for both - so it's best if that comes from a common source.
This is known as explicit instantiation declaration and you can read more about it in the Class template C++ reference.

48730: <p>My sketch contains 2 <code>.h</code> files. one defines</p>
<p>on 1st <code>.h</code> file:</p>
<pre><code>#define JSON_SIZE_IOT 400
#define JSON_SIZE_SKETCH 300
StaticJsonDocument&lt;JSON_SIZE_IOT&gt; paramJSON;
StaticJsonDocument&lt;JSON_SIZE_SKETCH&gt; sketchJSON;
</code></pre>
<p>and other need to define <code>paramJSON</code> and <code>sketchJSON</code> as <code>extern</code></p>
<p>on 2nd <code>.h</code> file:</p>
<pre><code>extern JsonDocument paramJSON;
extern JsonDocument paramJSON;
</code></pre>
<p>but I get this error:</p>
<pre><code>error: conflicting declaration 'ArduinoJson6172_91::StaticJsonDocument&lt;400u&gt; paramJSON'
 StaticJsonDocument&lt;JSON_SIZE_IOT&gt; paramJSON;
</code></pre>
<p>....</p>
<pre><code>: previous declaration as 'ArduinoJson6172_91::JsonDocument paramJSON'
 extern JsonDocument paramJSON;
</code></pre>
 4143: <p>For an <code>extern</code> the whole definition has to match the &quot;master&quot; definition.</p>
<p>So if you have:</p>
<pre class="lang-cpp prettyprint-override"><code>StaticJsonDocument&lt;JSON_SIZE_IOT&gt; paramJSON;
</code></pre>
<p>then you <code>extern</code> has to be:</p>
<pre class="lang-cpp prettyprint-override"><code>extern StaticJsonDocument&lt;JSON_SIZE_IOT&gt; paramJSON;
</code></pre>
<p>Of course you have to make sure your <code>JSON_SIZE_IOT</code> is the same for both - so it's best if that comes from a common source.</p>
<p>This is known as <em>explicit instantiation declaration</em> and you can read more about it in the <a href="https://en.cppreference.com/w/cpp/language/class_template" rel="nofollow noreferrer">Class template C++ reference</a>.</p>
