From 91d43934aa2cee36d6b5dbea5eff0505cff7ced4 Mon Sep 17 00:00:00 2001 From: Your Name <you@example.com> Date: Tue, 25 May 2021 19:15:23 +0200 Subject: [PATCH] Fix problem with linux --- CMakeLists.txt | 2 ++ include/blc_array.h | 5 +++++ include/blc_image.h | 6 +++++- include/blc_tools.h | 2 +- src/channel/blc_channel.cpp | 31 ++++++++++++--------------- src/core/blc_array.cpp | 7 ++++-- src/image/blc_image.cpp | 2 ++ src/network/blc_array_tcp4_client.cpp | 1 + src/network/blc_array_tcp4_server.cpp | 1 + src/network/blc_network.cpp | 10 +++++---- 10 files changed, 42 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86c61c0..c43a8de 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 83b5fe5..536f8ff 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 094fe98..de6258a 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 2b6a938..e092657 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/channel/blc_channel.cpp b/src/channel/blc_channel.cpp index 9bb8e15..1901bba 100644 --- a/src/channel/blc_channel.cpp +++ b/src/channel/blc_channel.cpp @@ -7,12 +7,12 @@ This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, - Â users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. - Â In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, - Â that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. + users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. + In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured - Â and, more generally, to use and operate it in the same conditions as regards security. - Â The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms. * + and, more generally, to use and operate it in the same conditions as regards security. + The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms. * Created on: Oct 9, 2014 @@ -453,18 +453,15 @@ int blc_channel::create_or_open(char const *new_name, int access_mode, uint32_t } ///Create a blc channel -/*int blc_channel::create_or_open(char const *new_name, int access_mode, uint32_t type, uint32_t format, vector<size_t> lengths){ - int dims_nb; - blc_dim dims[BLC_ARRAY_DIMS_MAX]; - - size_t size= - dims_nb = lengths.size(); - for (int i; i!=dims_nb; i++) { - dims[i].step=; - dims[i].length=lengths[i]; - } - return create_or_open(new_name, access_mode, type, format, dims_nb, dims); - }*/ +int blc_channel::create_or_open(char const *new_name, int access_mode, uint32_t type, uint32_t format, vector<size_t> lengths){ + int dims_nb; + blc_dim dims[BLC_ARRAY_DIMS_MAX]; + dims_nb = lengths.size(); + for (int i; i!=dims_nb; i++) { + dims[i].length=lengths[i]; + } + return create_or_open(new_name, access_mode, type, format, dims_nb, dims); +} int blc_channel::create_or_open(char const *new_name, int mode, uint32_t type, uint32_t format, char const *dims_string){ int created=1; diff --git a/src/core/blc_array.cpp b/src/core/blc_array.cpp index 8c64a89..80bb53b 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 5e85733..0a6ea17 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 f305c8c..cdf972e 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 c6ffb12..07d946f 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 4e7b2c6..c20b020 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); -- GitLab