-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ builds fail with modern C++ compilers #21073
Comments
|
While we could fix this particular failure by asking upstreams not to use I remember two reasons that have been mentioned for testing with C++:
I think 1. is useful, but rather than requiring that the whole of perl build with C++, I think it would be better to limit that to the headers, this reduces the load on our upstreams and lets us use C features in most code without the worry that they aren't supported in C++. I think the stricter type checking is close to nonsense, the only stricter type check I'm aware of for our purposes is the requirement to cast |
|
I do my development using g++. This is a habit from when C++ was new, and was billed as a better C, even if one didn't use the OO capabilities, and the C++ compiler was merely a preprocessor that translated the source to C (Cfront). Since then the languages have diverged more. I don't know the current state of the advantages of C++ compilers over C, if any. |
This can be true, though I think it mostly depended on using C++ features (like new and delete). Some of the problem with C vs C++ is some compilers only warn on code the C standard considers ill-formed code, like passing an gcc warns on such code, g++ throws an error, even though it's ill-formed in both languages. But in terms of progress on this, I can see us making a local change to remove The win32 Makefiles' gcc vs g++ |
Then we should possibly just revert ab28d72. As far as I can tell it doesn't really do anything functionally anyway. |
|
@Leont's idea seems reasonable to me |
Adding a strategically placed |
|
There's two separate problems:
We could just revert ab28d72 to undo the initialisers, but that still leaves |
|
Ahh except it seems a trivial revert isn't sufficient because it conflicts. and in any case that original commit looks like it should have changed |
This is what most projects I'm familiar with do. systemd has a batch of tests for this, for example.
RIght, C and C++ have different semantics, and while it might complain about some things, Perl is a C project, and any C++ warnings can't be taken literally because while the syntax is often the same, there's different rules about conversions and the rest of it. |
Addresses Perl#21073 (but isn't a fix)
|
There are some additional constructs causing problems with MSVC C++ builds:
There were some other more generic C++ issues. Fixed by #21096, though I haven't updated version numbers (two modules are in cpan/) * bearing in mind I haven't written C++ in a long, long time. |
The second came up while trying to get perl to build as C++ in MSVC 2022. Addresses Perl#21073 (but isn't a fix)
clang-16 rejects this, MSVC warns about it. Part of fixing Perl#21073
These aren't needed with modern perls, and it's only useful to
build modern perls as C++.
This was causing an error in a system header when building blead
as C++ with MSVC:
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\um\wspiapi.h(53):
error C2894: templates cannot be declared to have 'C' linkage
See Perl/perl5#21073 for more information
We often build blead perl using a C++ compiler, but C++17 removed the register storage specifier, so some newer C++ compilers which default to C++17 now throw an error. See Perl/perl5#21073 for more discussion
These aren't needed with modern perls, and it's only useful to
build modern perls as C++.
This was causing an error in a system header when building blead
as C++ with MSVC:
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\um\wspiapi.h(53):
error C2894: templates cannot be declared to have 'C' linkage
See Perl/perl5#21073 for more information
clang-16 rejects this, MSVC warns about it. Part of fixing Perl#21073
clang-16 rejects this, MSVC warns about it. Part of fixing #21073
The second came up while trying to get perl to build as C++ in MSVC 2022. Addresses #21073 (but isn't a fix)
clang-16 rejects this, MSVC warns about it. Part of fixing Perl#21073
The second came up while trying to get perl to build as C++ in MSVC 2022. Addresses Perl#21073 (but isn't a fix)
Module: Compress::Raw::Bzip2
Other modules may also be a problem.
Description
With a modern C++ compiler supporting and defaulting to C++ 17, the
registerstorage class modifier is no longer supported, which causes the build to fail:Note that at least one C99 construct we use isn't valid in C++:
(designated struct initialization is supported in C++20 but not arrays)
Steps to Reproduce
Expected behavior
Successful build.
Workaround
Build with
-std=c++11, which changes the message to a warning:Perl configuration
The text was updated successfully, but these errors were encountered: