[Development] suggested change to Q_INIT_RESOURCES

Scott Bloom scott at towel42.com
Wed Nov 19 18:31:12 CET 2025


With some minor tweaks, it turns out it all comes down to the error message the MSVC was giving, C2598, that linkage can only be set at the global scope.

example.cpp
<source>(3): error C2598: linkage specification must be at global scope
Compiler returned: 2

https://gcc.godbolt.org/z/xhrqees17

Fixes the "problem" but removes the solution as a possibility.

Maybe a Q_INIT_RESOURCES_DECL to be used at the global scope would make sense?

Scott




-----Original Message-----
From: Development <development-bounces at qt-project.org> On Behalf Of Thiago Macieira
Sent: Tuesday, November 18, 2025 17:56
To: development at qt-project.org
Subject: Re: [Development] suggested change to Q_INIT_RESOURCES

On Tuesday, 18 November 2025 11:54:38 Pacific Standard Time Scott Bloom wrote:
> Currently the macro declares the function qInitResource_XXXX with
> 
> extern int QT_MANGLE_NAMESPACE( qInitResource_ ## name )()
>
> I would like to suggest its changed to
> 
> extern “C++” int QT_MANGLE_NAMESPACE( qInitResource_ ## name )()
[snip]
> Changing the macro would fix this with zero downside.
> 
> Thought?

It doesn't compile. Use of extern "C++" there is not allowed by the language.
 https://gcc.godbolt.org/z/Kjrvb3bfv

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCG - Platform & Sys. Eng.


More information about the Development mailing list