Skip to content

Commit

Permalink
Cxx: Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
agdavydov81 committed Oct 16, 2023
1 parent 716d8c8 commit a15cb02
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
14 changes: 8 additions & 6 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ target_compile_definitions(dfpStatic PRIVATE API_PREFIX=ddfp${VERSION_SUFFIX}_ N
set_target_properties(dfpStatic PROPERTIES OUTPUT_NAME "ddfpStatic${VERSION_SUFFIX}")
install(TARGETS dfpStatic DESTINATION ./bin/${CMAKE_BUILD_TYPE}/${INSTALL_SUFFIX})

add_executable(demo demo.cpp)
#target_link_libraries(demo LINK_PRIVATE dfp stdc++)
if (MSVC)
target_link_libraries(demo LINK_PRIVATE dfpStatic)
else()
target_link_libraries(demo LINK_PRIVATE dfpStatic stdc++)
if (NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_executable(demo demo.cpp)
#target_link_libraries(demo LINK_PRIVATE dfp stdc++)
if (MSVC)
target_link_libraries(demo LINK_PRIVATE dfpStatic)
else()
target_link_libraries(demo LINK_PRIVATE dfpStatic stdc++)
endif()
endif()
7 changes: 5 additions & 2 deletions native/NativeImplToString.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <bid_internal.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include "NativeImplToString.h"

static const BID_UINT64 DFP_NAN_NULL = 0xFFFFFFFFFFFFFF80ull; // = -0x80L;
Expand Down Expand Up @@ -105,8 +107,9 @@ int numberOfDigits(BID_UINT64 value) {
return 19;
}

static const int bufferMinLength = 511;
_Thread_local char tls_to_string_buffer[bufferMinLength + 1];
#define bufferMinLength 511
#define bufferMinLengthWithZero 512
static _Thread_local char tls_to_string_buffer[bufferMinLengthWithZero];

BID_EXTERN_C const char* dfp64_to_string(BID_UINT64 value) {
return dfp64_to_string_2(value, '.');
Expand Down
12 changes: 7 additions & 5 deletions native/buildLinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -Eeuo pipefail
set -x

CCOMPILER=${2:-clang}
CXXCOMPILER=${2:-clang}
VERBOSE=${3:-ON}
CXXCOMPILER=${3:-clang}
VERBOSE=${4:-ON}

rm -rf ./build
mkdir build
Expand All @@ -25,11 +25,13 @@ make install

rm -rf ./*
cmake -G "Unix Makefiles" -DVERSION_SUFFIX=$1 -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE -DCMAKE_C_COMPILER=$CCOMPILER -DCMAKE_CXX_COMPILER=$CXXCOMPILER -DCMAKE_INSTALL_PREFIX=../ -DINSTALL_SUFFIX=linux/amd64 ../
make install
cmake --build . --config Release
cmake --install . --config Release

rm -rf ./*
cmake -G "Unix Makefiles" -DVERSION_SUFFIX=$1 -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE -DCMAKE_C_COMPILER=musl-gcc -DCMAKE_CXX_COMPILER=musl-gcc -DCMAKE_C_FLAGS_IN=-static -DCMAKE_INSTALL_PREFIX=../ -DINSTALL_SUFFIX=linux/amd64/musl-gcc ../
make install
cmake -G "Unix Makefiles" -DVERSION_SUFFIX=$1 -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE -DCMAKE_C_COMPILER=musl-gcc -DCMAKE_CXX_COMPILER=musl-gcc -DCMAKE_C_FLAGS_IN=-static -DCMAKE_CXX_FLAGS_IN=-static -DCMAKE_INSTALL_PREFIX=../ -DINSTALL_SUFFIX=linux/amd64/musl-gcc ../
cmake --build . --config Release
cmake --install . --config Release

cd ..
rm -rf ./build

0 comments on commit a15cb02

Please sign in to comment.