BewareMyPower opened a new pull request, #302:
URL: https://github.com/apache/pulsar-client-cpp/pull/302

   ### Motivation
   
   When building the project with the `-DCMAKE_CXX_STANDARD=20` option and GCC 
11.3, it failed. There are two main reasons.
   
   One is the `ObjectPool.h`, see http://eel.is/c++draft/diff.cpp17.class#2
   
   In short, see the code below:
   
   ```c++
   template <typename T>
   struct A {
     // A<T>() {}  // error: simple-template-id not allowed for constructor
     A() {}        // OK, injected-class-name used
   };
   ```
   
   The other reason is deeply hidden and OS-specific. When building the target 
for the unit test, the `lib/` directory is added into the include directories. 
So for `#include "Semaphore.h"`, the `Semaphore.h` header will be looked up 
first in the `lib/` directory. However, C++20 introduced a `<semaphore>` 
header, which finds the POSIX semaphore header `semaphore.h` in the system path.
   
   For example, the include order in `ubuntu:22.04` arm64 container is:
   - `$PROJECT_DIR/lib/` (where `Semaphore.h` is)
   - ...
   - `/usr/lib/gcc/aarch64-linux-gnu/11/include` (where `semaphore.h` is)
   
   The C++ header is case insensitive so the `lib/Semaphore.h` will be included 
by the `<semaphore>` header, which is implicitly included by `<thread>`. Our 
own `Semaphore.h` does not have the POSIX semaphore struct definitions so the 
build failed.
   
   ### Modifications
   
   - Fix the semantics error in `ObjectPool.h`
   - Remove the `lib/` directory from the included directories of the unit test 
and include `lib/xxx.h` for header in `lib/` directory.
   - Add a workflow to verify now it can be built with C++20


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to