[Development] suggested change to Q_INIT_RESOURCES

Scott Bloom scott at towel42.com
Tue Nov 18 20:54:38 CET 2025


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 )()

The reason being is the following use case, I have a plugin (not a qt plugin, but a plugin that uses qt including the resource system).

The main external API function call is defined as
extern “C” void apiCall()
{
Q_INIT_RESOURCE( resource );
}

Which causes a link error because the declaration of qInitResource_XXX is extern int, but gets done under extern “C” language linking.

The working around for me, is to declare the apiCall and then define it.

extern “C” void apiCall()

void apiCall()
{
Q_INIT_RESOURCE( resource );
}

But while this seems awfully trivial now, it took me way too long to figure out what was going on  😊

Changing the macro would fix this with zero downside.

Thought?

Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20251118/a4aaee17/attachment.htm>


More information about the Development mailing list