ICU 78.1: C4275 in GregorianCalendar and NumberFormat

27 views
Skip to first unread message

Christian Maurer

unread,
Nov 26, 2025, 7:53:51 AM11/26/25
to icu-support
Hi all!

In ICU 78.1 I get the warning "C4275: non dll-interface class 'icu_78::Calendar' used as base for dll-interface class 'icu_78::GregorianCalendar'.

Im am building with 'Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35221 for x64' using the options:
/std:c++20 /EHsc /W3

Testcase:
#include <iostream>
#include <unicode/gregocal.h>

int main(int argc, char *argv[])
{
    UErrorCode status = U_ZERO_ERROR;
    icu::GregorianCalendar cal(status);

    if (U_FAILURE(status)) {
        std::cerr << "Error creating GregorianCalendar\n";
        return 1;
    }

    return 0;
}


Relevant output:
ICU\78.1\include\unicode/gregocal.h(153): warning C4275: non dll-interface class 'icu_78::Calendar' used as base for dll-interface class 'icu_78::GregorianCalendar'
ICU\78.1\include\unicode/calendar.h(189): note: see declaration of 'icu_78::Calendar'
ICU\78.1\include\unicode/gregocal.h(153): note: see declaration of 'icu_78::GregorianCalendar'



The same happens for NumberFormat / Format:
ICU\78.1\include\unicode/numfmt.h(175): warning C4275: non dll-interface class 'icu_78::Format' used as base for dll-interface class 'icu_78::NumberFormat'
ICU\78.1\include\unicode/format.h(98): note: see declaration of 'icu_78::Format'
ICU\78.1\include\unicode/numfmt.h(175): note: see declaration of 'icu_78::NumberFormat'

In ICU 76.1 there was no such warning.

AFAIK it is not allowed to exclude a base class from the DLL export?

Fredrik Roubert

unread,
Nov 26, 2025, 9:17:38 AM11/26/25
to Christian Maurer, icu-support
On Wed, Nov 26, 2025 at 1:53 PM Christian Maurer <c.mau...@gmail.com> wrote:

> In ICU 76.1 there was no such warning.

This is new in ICU 78, it's a side-effect of this change to exclude
private class members from the DLL interface:

https://unicode-org.atlassian.net/browse/ICU-23136

> AFAIK it is not allowed to exclude a base class from the DLL export?

I don't have the faintest idea, but if you're able to figure out what
the warning really means and if there are any changes that ought to be
made to ICU then I'd be most interested to learn about that.

--
Fredrik Roubert
rou...@google.com

Christian Maurer

unread,
Dec 12, 2025, 6:34:04 AM12/12/25
to icu-support, Fredrik Roubert, icu-support, Christian Maurer
Hi Frederik,

Sorry for the delay!

I found this stackoverflow entry: 
Which references:

As far as I understand the issue, the compiler using the ICU library does not see the base class, because it is not exported. To create the class it has to make assumptions about the base class with possibly incomplete information. That is why in the Microsoft article the static components are being mentioned - creating objects in the static initialization phase does not happen if the class is not known.

Even if there are no static parts in these base classes at the moment, you would always have to guard against it in future changes. And the users of icu4c will have to trust your thoroughness and ignore/suppress the warning.

I am no expert on library design unfortunately. Maybe it would help if you export the base class and protect/hide the sensitive parts via smart (unique/shared) pointers to non-exported classes?

Best regards,
Christian
Reply all
Reply to author
Forward
0 new messages