Skip to content
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

GH-425 and GH-438 Update SSLeay.xs to support C++ compilers #451

Merged
merged 3 commits into from
Dec 10, 2023

Conversation

h-vn
Copy link
Contributor

@h-vn h-vn commented Dec 10, 2023

Perl can be built with a C++ compiler and therefore it's useful to update SSLeay.xs so that it can be built with a C++ compiler too. This PR does exactly this. See #425 and #438 for more information.

h-vn added 2 commits December 10, 2023 14:48

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…om 'void *'.

C allows implicit pointer conversion to and from 'void *'. C++ does not allow
this. Support C++ compilers by avoiding implicit conversion or by adding
explicit cast to where conversion is needed.
…l to 'char *.

In C string literals do not have the 'const' qualifier but in C++ they do.
Avoid C++ compiler warnings by changing our TRACE() funciton definition to use
'const char *' instead of plain 'char *'. This is a useful change for C too
because they string passed to the function can be expected to be read-only.
@h-vn h-vn added the enhancement New feature or request label Dec 10, 2023
@h-vn h-vn self-assigned this Dec 10, 2023
'extern "C" {}' block has wrapped Perl XS standard includes since the
beginning.  The earliest version found from the net is Net_SSLeay.pm version
0.4 in which the following was already present:

  #ifdef __cplusplus
  extern "C" {
  #endif
  #include "EXTERN.h"
  #include "perl.h"
  #include "XSUB.h"
  #ifdef __cplusplus
  }
  #endif

This has been carried over since then, until the recent SSLeay.xs updates to
allow compilation with a C++ compiler caused a compilation failure.

Recent GCC and Clang C++ compilers do not care about the 'extern "C"' wrapper
but Visual Studio Community 2022 flagged the following error (see GH-438):

C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\wspiapi.h(53):
error C2894: templates cannot be declared to have 'C ' linkage

When 'extern "C" {}' is removed completely, the compilation succeeds. This
makes sense since apparently the purpose of 'extern "C" {}' is to wrap one's
own functions instead of headers included from elsewhere. Those headers should
have their own 'extern "C" {}' definitions, if any are needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant