diff --git a/CMakeLists.txt b/CMakeLists.txt index 86c61c03e1e1d78ab19b40aae0d8c893edcd1134..c43a8de27ec3272d3e1f708748f99a126ce2e1f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ add_library(objlib OBJECT add_library(blc SHARED $<TARGET_OBJECTS:objlib>) add_library(static_blc STATIC $<TARGET_OBJECTS:objlib>) +set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE ON) #equivalent to -fPIC in gcc + target_compile_options(objlib PRIVATE -Wno-multichar) target_compile_features(objlib PRIVATE cxx_std_14) diff --git a/include/blc_array.h b/include/blc_array.h index 83b5fe51a82e051734f310100a08b4120441b47a..536f8ffa3e47864fbaca6fb547d17dcfc8b218c2 100644 --- a/include/blc_array.h +++ b/include/blc_array.h @@ -24,7 +24,12 @@ #define BLC_ARRAY_DIMS_MAX 8 #ifdef __cplusplus #include <vector> +#include <cstddef> +using namespace std; // to avoid std::size_t +#else +#include <stddef.h> #endif + /** @defgroup blc_array blc_array @{ diff --git a/include/blc_image.h b/include/blc_image.h index 094fe980b384db1ccbaf77eb8ef1510a57c6f0c5..de6258a2ff94627d6974d5b06bbde8ebdf7b8165 100644 --- a/include/blc_image.h +++ b/include/blc_image.h @@ -28,14 +28,18 @@ Specific functions to manipulate blc_array as images: #define BLC_IMAGE_H #include "stdint.h" //uint32_t -#include <array> #include "blc_array.h" + /** @defgroup blc_image blc_image functions @{ */ #ifdef __cplusplus +#include <array> +#include <functional> +#include <cstddef> +using namespace std; //for using size_t struct blc_image:blc_array{ ///Define but do not allocate data (use nulptr if you do not havec as well diff --git a/include/blc_tools.h b/include/blc_tools.h index 2b6a93884af63557c4c762474254f82a7cad0028..e0926576cefe23d0d70898b38824fdeded87925e 100644 --- a/include/blc_tools.h +++ b/include/blc_tools.h @@ -40,7 +40,7 @@ std::string uint32_to_string(uint32_t value); #include <stdio.h> /* FILE* */ #include <stdlib.h> /* size_t */ -#include <stdarg.h> /* variable arguments ... */ +//.#include <stdarg.h> /* variable arguments ... */ #include <string.h> /*memset*/ #include <stdint.h> /* uint32_t */ #include <sys/param.h> diff --git a/src/core/blc_array.cpp b/src/core/blc_array.cpp index 8c64a89dbf41c0cc8ba29b14051d8e2ebfd64182..80bb53bdc6c1a6aa23fcad48d1399970db819865 100644 --- a/src/core/blc_array.cpp +++ b/src/core/blc_array.cpp @@ -23,6 +23,9 @@ #include <stdio.h> //fopen #include <algorithm> //copy #include <vector> +#include <stdexcept> +#include <cassert> + using namespace std; @@ -40,7 +43,7 @@ void blc_array::def_array(uint32_t type, uint32_t format, vector<size_t> const & } void blc_array::def_array(uint32_t type, uint32_t format, int dims_nb, blc_dim const dims[BLC_ARRAY_DIMS_MAX]){ - assert(dims_nb<=BLC_ARRAY_DIMS_MAX); + if (dims_nb>BLC_ARRAY_DIMS_MAX) throw length_error("too many dims max"); this->type=type; this->format=format; this->dims_nb=dims_nb; @@ -57,7 +60,7 @@ void blc_array::def_array(uint32_t type, uint32_t format, char const *dims_strin } void blc_array::set_dims(uint32_t type, vector<size_t> const &lengths){ - assert(lengths.size()<=BLC_ARRAY_DIMS_MAX); + if (dims_nb>BLC_ARRAY_DIMS_MAX) throw length_error("too many dims max"); dims_nb=lengths.size(); size=blc_get_type_size(type); size_t length; diff --git a/src/image/blc_image.cpp b/src/image/blc_image.cpp index 5e85733d879ce9a1d58c04d2e3d9d41f35f3579a..0a6ea178ed5fab2ed54e1b92d35ca54c4060d91e 100644 --- a/src/image/blc_image.cpp +++ b/src/image/blc_image.cpp @@ -28,6 +28,8 @@ #include <stdexcept> //invalid_argument #include <variant> #include <iostream> +#include <algorithm> + using namespace std; diff --git a/src/network/blc_array_tcp4_client.cpp b/src/network/blc_array_tcp4_client.cpp index f305c8ce09e145cad5cd3473d662427f2e8bb4a6..cdf972e07d44a74aa82c4fe9351a825f52963a76 100644 --- a/src/network/blc_array_tcp4_client.cpp +++ b/src/network/blc_array_tcp4_client.cpp @@ -10,6 +10,7 @@ #include <unistd.h> #include <netinet/tcp.h> #include <vector> +#include <cstdarg> using namespace std; diff --git a/src/network/blc_array_tcp4_server.cpp b/src/network/blc_array_tcp4_server.cpp index c6ffb12e6e8a4e2df15a5116715ebc6e81d9a86b..07d946f79f712a7111520efb35286f146bc9ac40 100644 --- a/src/network/blc_array_tcp4_server.cpp +++ b/src/network/blc_array_tcp4_server.cpp @@ -7,6 +7,7 @@ #include <unistd.h> #include <netinet/tcp.h> #include <vector> +#include <cstdarg> using namespace std; diff --git a/src/network/blc_network.cpp b/src/network/blc_network.cpp index 4e7b2c65cdf73961766720e647a9c53bdddcface..c20b02030fb15d154150ad3940aad6fb1faae7da 100644 --- a/src/network/blc_network.cpp +++ b/src/network/blc_network.cpp @@ -17,18 +17,20 @@ #include <sys/ioctl.h> #include <net/if.h> #include <string> +#include <stdarg.h> -using namespace std; + +//using namespace std; static int blc_vset_iovec(struct iovec *iov, void *data, size_t size, va_list arguments){ int len; - for(len=0; data != NULL; len++) + for(len=0; data != nullptr; len++) { iov[len].iov_base = data; iov[len].iov_len = size; data = va_arg(arguments, void*); - size = va_arg(arguments, size_t); + size = va_arg(arguments, double); } return len; @@ -37,7 +39,7 @@ int blc_set_iovec(struct iovec *iovec, void *data, size_t size, ...) { int len; va_list arguments; - + va_start(arguments, size); len = blc_vset_iovec(iovec, data, size, arguments); va_end(arguments);