qicosmos / cinatra

modern c++(c++20), cross-platform, header-only, easy to use http framework
MIT License
1.88k stars 372 forks source link

Integrate with the existing boost asio #627

Open codingl2k1 opened 1 month ago

codingl2k1 commented 1 month ago

My project already has boost asio. However, I need to modify the source code of cinatra to integrate it with the existing boost asio. Is it possible to provide a macro or something to make this easier?

qicosmos commented 1 month ago

could you provide detail error messages?

codingl2k1 commented 1 month ago

For example,

cinatra/cinatra/coro_http_client.hpp:19:10: fatal error: 'asio/dispatch.hpp' file not found
#include "asio/dispatch.hpp"
         ^~~~~~~~~~~~~~~~~~~

I have to change it to #include <boost/asio/dispatch.hpp>.

Also, there are many compilation warnings when I compiles with clang:

cinatra/cinatra/multipart.hpp:28:12: error: unused variable 'last_size' [-Werror,-Wunused-variable]
    size_t last_size = chunked_buf_.size();
           ^
cinatra/cinatra/uri.hpp:280:7: error: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Werror,-Wdeprecated-declarations]
      sprintf(buf_hex, "%X", c);
      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:180:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:218:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^

My clang version is:

Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin