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

Fixing example files compilation #551

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions examples/build/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ include_directories (../../include

file(GLOB_RECURSE Example_sources ../../src/*.cpp)

add_executable (jsoncons_examples ${Example_sources})

if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# special link option on Linux because llvm stl rely on GNU stl
target_link_libraries (jsoncons_examples -Wl,-lstdc++)
endif()
# Loop through each example file and create an executable for each
foreach(example_file ${Example_sources})
# Extract the filename without path and extension
get_filename_component(example_name ${example_file} NAME_WE)

# Create an executable with the example name and file
add_executable(${example_name} ${example_file})

if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# special link option on Linux because llvm stl rely on GNU stl
target_link_libraries(${example_name} -Wl,-lstdc++)
endif()
endforeach()
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include <jsoncons/json.hpp>
#include <iomanip>
#include <assert.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace jsoncons;
namespace boost_mp = boost::multiprecision;

void serialization_example1()
{
Expand Down Expand Up @@ -409,7 +411,8 @@ void bignum_access_examples()
// If your compiler supports extended integral types
#if (defined(__GNUC__) || defined(__clang__)) && defined(JSONCONS_HAS_INT128)
__int128 i = j.as<__int128>();
std::cout << "(4) " << i << "\n\n";
boost_mp::int128_t boost_i = static_cast<boost_mp::int128_t>(i);
std::cout << "(4) " << boost_i << "\n\n";
#endif
}

Expand Down Expand Up @@ -485,7 +488,9 @@ int main()
decimal_precision_examples();
bignum_access_examples();
chinese_char();
chinese_uchar8_t();
#ifdef __cpp_char8_t
chinese_uchar8_t();
#endif
std::cout << std::endl;
}

Loading