# HG changeset patch # User Markus Mützel # Date 1609011951 -3600 # Sat Dec 26 20:45:51 2020 +0100 # Node ID e4f9ea6c5df944502f8f96db8b77737e70b6c2df # Parent 3e2a56ea84fe022eb5a307041837ebad3a494923 Fixes for building with visibility flags for Windows (patch #8919). * liboctave/util/lo-utils.h: Don't define function that is imported with dllimport. * liboctave/util/lo-utils.cc: Define template. Instantiate it with Octave integer types. * src/main.in.cc, src/mkoctfile.in.cc: Do not dllimport when linking to static lib. diff -r 3e2a56ea84fe -r e4f9ea6c5df9 liboctave/util/lo-utils.cc --- a/liboctave/util/lo-utils.cc Sat Dec 26 10:07:32 2020 +0100 +++ b/liboctave/util/lo-utils.cc Sat Dec 26 20:45:51 2020 +0100 @@ -43,6 +43,7 @@ #include "lo-ieee.h" #include "lo-mappers.h" #include "lo-utils.h" +#include "oct-inttypes.h" bool xis_int_or_inf_or_nan (double x) { return octave::math::isnan (x) || octave::math::x_nint (x) == x; } @@ -178,6 +179,25 @@ namespace octave { + template + T + read_value (std::istream& is) + { + T retval; + is >> retval; + return retval; + } + + template bool read_value (std::istream& is); + template octave_int8 read_value (std::istream& is); + template octave_int16 read_value (std::istream& is); + template octave_int32 read_value (std::istream& is); + template octave_int64 read_value (std::istream& is); + template octave_uint8 read_value (std::istream& is); + template octave_uint16 read_value (std::istream& is); + template octave_uint32 read_value (std::istream& is); + template octave_uint64 read_value (std::istream& is); + // Note that the caller is responsible for repositioning the stream on // failure. @@ -378,6 +398,23 @@ return read_cx_fp_value (is); } + template + void + write_value (std::ostream& os, const T& value) + { + os << value; + } + + template void write_value (std::ostream& os, const bool& value); + template void write_value (std::ostream& os, const octave_int8& value); + template void write_value (std::ostream& os, const octave_int16& value); + template void write_value (std::ostream& os, const octave_int32& value); + template void write_value (std::ostream& os, const octave_int64& value); + template void write_value (std::ostream& os, const octave_uint8& value); + template void write_value (std::ostream& os, const octave_uint16& value); + template void write_value (std::ostream& os, const octave_uint32& value); + template void write_value (std::ostream& os, const octave_uint64& value); + // Note: precision is supposed to be managed outside of this function by // setting stream parameters. diff -r 3e2a56ea84fe -r e4f9ea6c5df9 liboctave/util/lo-utils.h --- a/liboctave/util/lo-utils.h Sat Dec 26 10:07:32 2020 +0100 +++ b/liboctave/util/lo-utils.h Sat Dec 26 20:45:51 2020 +0100 @@ -98,28 +98,14 @@ namespace octave { - template - OCTAVE_API - T - read_value (std::istream& is) - { - T retval; - is >> retval; - return retval; - } + template OCTAVE_API T read_value (std::istream& is); template <> double read_value (std::istream& is); template <> Complex read_value (std::istream& is); template <> float read_value (std::istream& is); template <> FloatComplex read_value (std::istream& is); - template - OCTAVE_API - void - write_value (std::ostream& os, const T& value) - { - os << value; - } + template OCTAVE_API void write_value (std::ostream& os, const T& value); template <> void write_value (std::ostream& os, const double& value); template <> void write_value (std::ostream& os, const Complex& value); diff -r 3e2a56ea84fe -r e4f9ea6c5df9 src/main.in.cc --- a/src/main.in.cc Sat Dec 26 10:07:32 2020 +0100 +++ b/src/main.in.cc Sat Dec 26 20:45:51 2020 +0100 @@ -43,6 +43,10 @@ #include #include +// We are linking against static libs so do not decorate with dllimport. +// FIXME: This should be done by the build system. +#undef OCTAVE_API +#define OCTAVE_API #include "fcntl-wrappers.h" #include "signal-wrappers.h" #include "unistd-wrappers.h" diff -r 3e2a56ea84fe -r e4f9ea6c5df9 src/mkoctfile.in.cc --- a/src/mkoctfile.in.cc Sat Dec 26 10:07:32 2020 +0100 +++ b/src/mkoctfile.in.cc Sat Dec 26 20:45:51 2020 +0100 @@ -60,6 +60,10 @@ # define OCTAVE_UNUSED # endif #else +// We are linking against static libs so do not decorate with dllimport. +// FIXME: This should be done by the build system. +# undef OCTAVE_API +# define OCTAVE_API # include "mkostemps-wrapper.h" # include "uniconv-wrappers.h" # include "unistd-wrappers.h" @@ -158,10 +162,11 @@ replace_prefix (std::string s) { const std::string match = "${prefix}"; + const std::string repl = prepend_octave_exec_home (""); size_t pos = s.find (match); while (pos != std::string::npos ) { - s.replace(pos, match.length (), prepend_octave_exec_home ("")); + s.replace(pos, match.length (), repl); pos = s.find (match); }