Skip to content

Commit

Permalink
Merge pull request #551 from 2208loki/run-examples
Browse files Browse the repository at this point in the history
Fixing example files compilation
  • Loading branch information
danielaparker authored Nov 10, 2024
2 parents 0a7743a + 0bd72b7 commit 0500622
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
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;
}

0 comments on commit 0500622

Please sign in to comment.