Skip to content

Support linkage from C++ modules

Michael Lee requested to merge ml2e2/wget2:fix-cpp-linkage into master

Fix issue: #612 (closed)

While 'restrict' is a reserved keyword in C99 (described in C99-6.4.1-1), it is not true in any standard of C++ (from C++11 to C++20). Since we cannot compile C++ modules with '-std=gnu99' option, we shall use GCC extension (i.e., '__restrict' or '__restrict__') to gain the similar or equivalent optimization benefits provided by compiler.

This is the same workaround adopted by GLIBC: https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/spawn.h;h=c4a81227b04490b817ed4a5784f2e5a47c4ccbf7;hb=HEAD#l72

Approver's checklist:

  • The author has submitted the FSF Copyright Assignment and is listed in AUTHORS
  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent with existing code
  • This feature/change has adequate documentation added (if appropriate)
  • No obvious mistakes / misspelling in the code

Merge request reports