From c63f8df0bc6f56a6302a599c5a037e71d7d8705a Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Wed, 6 Jul 2022 14:55:52 +0200 Subject: [PATCH] Require C++17 (#1893) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * flex: require >= 2.6 to avoid register keyword. * flex/c++ standard documentation and fixes. * Use std:: prefix on cout, endl, istream, ostream etc. * drop gcc5 and gcc6, do not explicitly specify default cmake option values. * Use newer python patch versions and target macOS 10.14 instead of 10.9. * Dockerfile: newer flex * Dockerfile_gpu: base on `latest-x86_64` * C++17 in submodules. * Require C++17 in CoreNEURON too -> BlueBrain/CoreNeuron#834. * Require C++17 in InterViews too-> iv#43 & Bump to C++17 iv#44. * Require C++17 in NMODL too -> BlueBrain/nmodl#889 Co-authored-by: Alexandru Săvulescu --- .clang-format.changes | 4 +- .github/workflows/neuron-ci.yml | 21 ++++--- CMakeLists.txt | 4 +- azure-pipelines.yml | 12 ++-- bin/nrnivmodl_makefile_cmake.in | 2 +- cmake/CompilerHelper.cmake | 6 -- docs/install/install_instructions.md | 4 +- external/coreneuron | 2 +- external/iv | 2 +- packaging/python/Dockerfile | 13 +++- packaging/python/Dockerfile_gpu | 2 +- src/ivoc/apwindow.cpp | 2 +- src/ivoc/axis.cpp | 6 +- src/ivoc/axis.h | 2 +- src/ivoc/epsprint.cpp | 4 +- src/ivoc/epsprint.h | 4 +- src/ivoc/graph.cpp | 88 ++++++++++++++-------------- src/ivoc/hocmark.h | 2 +- src/ivoc/idraw.cpp | 60 +++++++++---------- src/ivoc/idraw.h | 2 +- src/ivoc/ivoc.h | 3 +- src/ivoc/ivocmain.cpp | 2 +- src/ivoc/ocbox.cpp | 34 +++++------ src/ivoc/ocbox.h | 2 +- src/ivoc/ocdeck.cpp | 22 +++---- src/ivoc/ocdeck.h | 2 +- src/ivoc/pwman.cpp | 62 ++++++++++---------- src/ivoc/scene.cpp | 20 +++---- src/ivoc/utility.cpp | 4 +- src/ivoc/xmenu.cpp | 68 ++++++++++----------- src/ivoc/xmenu.h | 28 ++++----- src/ivoc/xyview.cpp | 8 +-- src/ivos/ivstream.h | 6 +- src/modlunit/units.cpp | 4 +- src/nrniv/nrnmenu.cpp | 2 +- src/nrniv/shape.cpp | 12 ++-- src/nrniv/shapeplt.cpp | 6 +- src/nrniv/spaceplt.cpp | 16 ++--- src/nrnoc/multicore.cpp | 3 +- 39 files changed, 276 insertions(+), 270 deletions(-) diff --git a/.clang-format.changes b/.clang-format.changes index 89f6960445..ffc90c1d4c 100644 --- a/.clang-format.changes +++ b/.clang-format.changes @@ -1,3 +1,3 @@ SortIncludes: false -Standard: c++14 -StatementMacros: [MKDLL, MKDLLdec, MKDLLif, MKDLLvp, MKDLLvpf] \ No newline at end of file +Standard: c++17 +StatementMacros: [MKDLL, MKDLLdec, MKDLLif, MKDLLvp, MKDLLvpf] diff --git a/.github/workflows/neuron-ci.yml b/.github/workflows/neuron-ci.yml index 4e394c3ce9..2b0e8fb4fd 100644 --- a/.github/workflows/neuron-ci.yml +++ b/.github/workflows/neuron-ci.yml @@ -43,12 +43,14 @@ jobs: matrix: os: [ macOS-10.15, ubuntu-18.04] config: - - { matrix_eval : "CC=gcc CXX=g++" , build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=ON -DNRN_ENABLE_INTERVIEWS=ON -DNRN_ENABLE_CORENEURON=ON" } - - { matrix_eval : "CC=gcc-8 CXX=g++-8", build_mode: "setuptools" } - - { matrix_eval : "CC=gcc-5 CXX=g++-5", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=OFF -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_CORENEURON=ON" } - - { matrix_eval : "CC=gcc-6 CXX=g++-6", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=ON -DNRN_ENABLE_INTERVIEWS=ON -DNRN_ENABLE_CORENEURON=OFF" } - - { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_PYTHON=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_CORENEURON=ON" } - - { matrix_eval : "CC=gcc-8 CXX=g++-8", build_mode: "cmake", python_dynamic : ON } + # GitHub Actions's ubuntu-18.04 image should provide g++ versions 9 and + # 10 even though those are not available in vanilla Ubuntu 18.04 + - { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "setuptools"} + - { matrix_eval : "CC=gcc-8 CXX=g++-8", build_mode: "cmake"} + - { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "cmake", python_dynamic: ON} + - { matrix_eval : "CC=gcc-7 CXX=g++-7" , build_mode: "cmake", cmake_option: "-DNRN_ENABLE_CORENEURON=ON"} + - { matrix_eval : "CC=gcc-7 CXX=g++-7", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=OFF -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_CORENEURON=ON"} + - { matrix_eval : "CC=gcc-10 CXX=g++-10", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_PYTHON=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_CORENEURON=ON"} include: - os: ubuntu-22.04 config: @@ -79,10 +81,11 @@ jobs: - name: Install homebrew packages if: startsWith(matrix.os, 'macOS') run: | - brew install ccache coreutils doxygen mpich ninja xz + brew install ccache coreutils doxygen flex mpich ninja xz brew unlink mpich brew install openmpi brew install --cask xquartz + echo /usr/local/opt/flex/bin >> $GITHUB_PATH # Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources echo CMAKE_BUILD_PARALLEL_LEVEL=3 >> $GITHUB_ENV echo CTEST_PARALLEL_LEVEL=3 >> $GITHUB_ENV @@ -97,7 +100,7 @@ jobs: openmpi-bin patchelf # The sanitizer builds use ubuntu 22.04 if [[ "${{matrix.os}}" == "ubuntu-18.04" ]]; then - sudo apt-get install g++-5 g++-6 g++-8 g++-9 + sudo apt-get install g++-7 g++-8 fi # Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources echo CMAKE_BUILD_PARALLEL_LEVEL=2 >> $GITHUB_ENV @@ -165,7 +168,7 @@ jobs: run: | # OS related if [ "$RUNNER_OS" == "Linux" ]; then - eval $MATRIX_EVAL; + export ${MATRIX_EVAL}; export SHELL="/bin/bash" else export CXX=${CXX:-g++}; diff --git a/CMakeLists.txt b/CMakeLists.txt index d6a29f408f..d98deef39f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ project( # ============================================================================= # CMake common project settings # ============================================================================= -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -251,7 +251,7 @@ include(cmake/SanitizerHelper.cmake) # Find required packages # ============================================================================= find_package(BISON REQUIRED) -find_package(FLEX REQUIRED) +find_package(FLEX 2.6 REQUIRED) # When shipping the wheels we want to link readline libs statically. if(NRN_WHEEL_STATIC_READLINE) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ea2631680d..bcbcac7ee7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -140,19 +140,19 @@ stages: matrix: Python37: python.version: '3.7' - python.org.version: '3.7.7' + python.org.version: '3.7.9' python.installer.name: 'macosx10.9.pkg' Python38: python.version: '3.8' - python.org.version: '3.8.2' + python.org.version: '3.8.10' python.installer.name: 'macosx10.9.pkg' Python39: python.version: '3.9' - python.org.version: '3.9.0' + python.org.version: '3.9.13' python.installer.name: 'macosx10.9.pkg' Python310: python.version: '3.10' - python.org.version: '3.10.0' + python.org.version: '3.10.5' python.installer.name: 'macos11.pkg' steps: @@ -186,8 +186,10 @@ stages: inputs: secureFile: 'readline7.0.tar.gz' + # 10.14 is required for full C++17 support, see: + # https://cibuildwheel.readthedocs.io/en/stable/cpp_standards - script: | - export MACOSX_DEPLOYMENT_TARGET=10.9 + export MACOSX_DEPLOYMENT_TARGET=10.14 export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) export NRN_BUILD_FOR_UPLOAD=1 diff --git a/bin/nrnivmodl_makefile_cmake.in b/bin/nrnivmodl_makefile_cmake.in index 1a32c4a337..acb2351519 100644 --- a/bin/nrnivmodl_makefile_cmake.in +++ b/bin/nrnivmodl_makefile_cmake.in @@ -65,7 +65,7 @@ endif ifeq ($(origin CXX), default) CXX = @CMAKE_CXX_COMPILER@ endif -CXXFLAGS = @BUILD_TYPE_CXX_FLAGS@ @CMAKE_CXX_FLAGS@ @CMAKE_CXX14_STANDARD_COMPILE_OPTION@ +CXXFLAGS = @BUILD_TYPE_CXX_FLAGS@ @CMAKE_CXX_FLAGS@ @CMAKE_CXX17_STANDARD_COMPILE_OPTION@ CXXCOMPILE = $(CXX) $(CXXFLAGS) @NRN_COMPILE_DEFS_STRING@ @NRN_COMPILE_FLAGS_STRING@ CXX_LINK_EXE = $(CXX) $(CXXFLAGS) @CMAKE_EXE_LINKER_FLAGS@ @NRN_LINK_FLAGS_STRING@ CXX_LINK_SHARED = $(CXX) $(CXXFLAGS) @CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS@ @CMAKE_SHARED_LIBRARY_CXX_FLAGS@ @CMAKE_SHARED_LINKER_FLAGS@ diff --git a/cmake/CompilerHelper.cmake b/cmake/CompilerHelper.cmake index c7b27e21d6..4ceb413db8 100644 --- a/cmake/CompilerHelper.cmake +++ b/cmake/CompilerHelper.cmake @@ -54,9 +54,3 @@ else() set(USING_PGI_COMPILER_TRUE "#") set(USING_PGI_COMPILER_FALSE "") endif() - -if(CMAKE_CXX_COMPILER_ID MATCHES "PGI") - # CMake adds strict standard complaint PGI flag "-A" which breaks compilation of old codes (e.g. - # spdlog, fmt) - set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14) -endif() diff --git a/docs/install/install_instructions.md b/docs/install/install_instructions.md index 070579e64c..78b3ea42b7 100644 --- a/docs/install/install_instructions.md +++ b/docs/install/install_instructions.md @@ -198,8 +198,8 @@ from source. In order to build NEURON from source, the following packages must be available: - Bison -- Flex -- C/C++ compiler suite +- Flex >= 2.6 +- C/C++ compiler suite supporting C++17 - CMake 3.15.0 The following packages are optional (see build options): diff --git a/external/coreneuron b/external/coreneuron index 0574812f77..511613efbd 160000 --- a/external/coreneuron +++ b/external/coreneuron @@ -1 +1 @@ -Subproject commit 0574812f772d6dde595f33913452f798bba5166e +Subproject commit 511613efbdf088bc7af5b69a769c147fd20328a5 diff --git a/external/iv b/external/iv index ea2b4b474e..24df191936 160000 --- a/external/iv +++ b/external/iv @@ -1 +1 @@ -Subproject commit ea2b4b474ec516c952e44c3b60e1c80fd3b9d666 +Subproject commit 24df191936b1c634eda706775e199f256639d2da diff --git a/packaging/python/Dockerfile b/packaging/python/Dockerfile index e49e34bd23..69c014b0df 100644 --- a/packaging/python/Dockerfile +++ b/packaging/python/Dockerfile @@ -12,14 +12,25 @@ RUN yum -y install \ curl \ unzip \ bison \ - flex \ autoconf \ automake \ openssh-server \ libtool + +# required for rpmbuild +RUN yum -y install \ + gettext \ + gcc-c++ \ + help2man \ + rpm-build WORKDIR /root +# newer flex with rpmbuild (manylinux2014 based on Centos7 currently has flex < 2.6) +RUN rpmbuild --rebuild https://vault.centos.org/8-stream/AppStream/Source/SPackages/flex-2.6.1-9.el8.src.rpm \ + && yum install -y /root/rpmbuild/RPMS/x86_64/flex-2.6.1-9.el7.x86_64.rpm \ + && rm -rf rpmbuild + RUN wget http://ftpmirror.gnu.org/ncurses/ncurses-6.2.tar.gz \ && tar -xvzf ncurses-6.2.tar.gz \ && cd ncurses-6.2 \ diff --git a/packaging/python/Dockerfile_gpu b/packaging/python/Dockerfile_gpu index 6dc7e8cdad..56fe7d582a 100644 --- a/packaging/python/Dockerfile_gpu +++ b/packaging/python/Dockerfile_gpu @@ -1,4 +1,4 @@ -FROM neuronsimulator/neuron_wheel +FROM neuronsimulator/neuron_wheel:latest-x86_64 LABEL authors="Pramod Kumbhar, Olli Lupton, Fernando Pereira, Alexandru Savulescu" WORKDIR /root diff --git a/src/ivoc/apwindow.cpp b/src/ivoc/apwindow.cpp index 026582a31b..430ad41159 100644 --- a/src/ivoc/apwindow.cpp +++ b/src/ivoc/apwindow.cpp @@ -563,7 +563,7 @@ void OcGlyph::def_size(Coord& w, Coord& h) const { } } -void OcGlyph::save(ostream&) { +void OcGlyph::save(std::ostream&) { printf("OcGlyph::save (not implemented for relevant class)\n"); } diff --git a/src/ivoc/axis.cpp b/src/ivoc/axis.cpp index da6bd05bdd..fbcfd0f2bf 100644 --- a/src/ivoc/axis.cpp +++ b/src/ivoc/axis.cpp @@ -21,7 +21,7 @@ GAxisItem(Glyph* g) : GraphItem(g) {} virtual ~GAxisItem(){}; - virtual void save(ostream&, Coord, Coord) {} + virtual void save(std::ostream&, Coord, Coord) {} virtual void erase(Scene* s, GlyphIndex i, int type) { if (type & GraphItem::ERASE_AXIS) { s->remove(i); @@ -85,7 +85,7 @@ void Axis::size(float& min, float& max) { max = float(amax_); } -void Axis::save(ostream& o) { +void Axis::save(std::ostream& o) { char buf[256]; int c; if (d_ == Dimension_X) { @@ -103,7 +103,7 @@ void Axis::save(ostream& o) { nminor_, invert_, number_); - o << buf << endl; + o << buf << std::endl; } void Axis::update(Observable*) {} diff --git a/src/ivoc/axis.h b/src/ivoc/axis.h index 8eaa918ada..3e6313b445 100644 --- a/src/ivoc/axis.h +++ b/src/ivoc/axis.h @@ -20,7 +20,7 @@ class Axis: public Glyph, public Observer { int invert = 0, bool number = true); virtual ~Axis(); - virtual void save(ostream&); + virtual void save(std::ostream&); virtual void update(Observable*); virtual void size(float&, float&); diff --git a/src/ivoc/epsprint.cpp b/src/ivoc/epsprint.cpp index 045946abfc..dfb4b0c366 100644 --- a/src/ivoc/epsprint.cpp +++ b/src/ivoc/epsprint.cpp @@ -30,12 +30,12 @@ save 20 dict begin\n\ \n\ "; -EPSPrinter::EPSPrinter(ostream* o) +EPSPrinter::EPSPrinter(std::ostream* o) : Printer(o) {} EPSPrinter::~EPSPrinter() {} -void EPSPrinter::eps_prolog(ostream& out, Coord width, Coord height, const char* creator) { +void EPSPrinter::eps_prolog(std::ostream& out, Coord width, Coord height, const char* creator) { int bbw = int(width); int bbh = int(height); // need to describe it as EPSF = "encapsulated postscript" diff --git a/src/ivoc/epsprint.h b/src/ivoc/epsprint.h index 07c8d3f6d3..a2bca59bcc 100644 --- a/src/ivoc/epsprint.h +++ b/src/ivoc/epsprint.h @@ -5,10 +5,10 @@ class EPSPrinter: public Printer { public: - EPSPrinter(ostream*); + EPSPrinter(std::ostream*); virtual ~EPSPrinter(); - virtual void eps_prolog(ostream&, + virtual void eps_prolog(std::ostream&, Coord width, Coord height, const char* creator = "InterViews"); diff --git a/src/ivoc/graph.cpp b/src/ivoc/graph.cpp index ab2fe247fc..e4301e2f50 100644 --- a/src/ivoc/graph.cpp +++ b/src/ivoc/graph.cpp @@ -82,7 +82,7 @@ bool GraphItem::is_mark() { GraphLabelItem(Glyph* g) : GraphItem(g) {} virtual ~GraphLabelItem(){}; - virtual void save(ostream& o, Coord x, Coord y) { + virtual void save(std::ostream& o, Coord x, Coord y) { ((GLabel*) body())->save(o, x, y); } virtual void erase(Scene* s, GlyphIndex i, int type) { @@ -97,7 +97,7 @@ bool GraphItem::is_mark() { GraphAxisItem(Glyph* g) : GraphItem(g) {} virtual ~GraphAxisItem(){}; - virtual void save(ostream& o, Coord, Coord) { + virtual void save(std::ostream& o, Coord, Coord) { ((Axis*) body())->save(o); } virtual void erase(Scene* s, GlyphIndex i, int type) { @@ -284,12 +284,12 @@ static double gr_save_name(void* v) { g->name(gargstr(1)); if (ifarg(2) && (chkarg(2, 0, 1) == 1.) && Oc::save_stream) { char buf[80]; - *Oc::save_stream << "{\nsave_window_=" << gargstr(1) << endl; + *Oc::save_stream << "{\nsave_window_=" << gargstr(1) << std::endl; *Oc::save_stream << "save_window_.size(" << g->x1() << "," << g->x2() << "," << g->y1() << "," << g->y2() << ")\n"; long i = Scene::scene_list_index(g); sprintf(buf, "scene_vector_[%ld] = save_window_", i); - *Oc::save_stream << buf << endl; + *Oc::save_stream << buf << std::endl; g->save_phase2(*Oc::save_stream); g->Scene::mark(true); } @@ -1353,7 +1353,7 @@ GraphItem::GraphItem(Glyph* g, bool s, bool p) pick_ = p; } GraphItem::~GraphItem() {} -void GraphItem::save(ostream&, Coord, Coord) {} +void GraphItem::save(std::ostream&, Coord, Coord) {} void GraphItem::erase(Scene*, GlyphIndex, int) {} void GraphItem::pick(Canvas* c, const Allocation& a, int depth, Hit& h) { if (pick_) { @@ -1593,13 +1593,13 @@ GlyphIndex Graph::glyph_index(const Glyph* gl) { return -1; } -ostream* Graph::ascii_; +std::ostream* Graph::ascii_; SymChooser* Graph::fsc_; -void Graph::ascii(ostream* o) { +void Graph::ascii(std::ostream* o) { ascii_ = o; } -ostream* Graph::ascii() { +std::ostream* Graph::ascii() { return ascii_; } @@ -1618,13 +1618,13 @@ void Graph::draw(Canvas* c, const Allocation& a) const { } } -void Graph::ascii_save(ostream& o) const { +void Graph::ascii_save(std::ostream& o) const { long line, lcnt = line_list_.count(); int i, dcnt; if (lcnt == 0 || !x_ || family_label_) { // tries to print in matrix form is labels and each line the same // size. - o << "PolyLines" << endl; + o << "PolyLines" << std::endl; if (x_expr_) { o << "x expression: " << x_expr_->name; } @@ -1633,7 +1633,7 @@ void Graph::ascii_save(ostream& o) const { for (i = 0; i < lcnt; ++i) { o << " " << line_list_.item(i)->name(); } - o << endl; + o << std::endl; } @@ -1676,8 +1676,8 @@ void Graph::ascii_save(ostream& o) const { } } } - o << endl; - o << xcnt << " rows, " << col + 1 << " columns" << endl; + o << std::endl; + o << xcnt << " rows, " << col + 1 << " columns" << std::endl; int j; for (j = 0; j < xcnt; ++j) { o << xvec->get_val(j); @@ -1690,11 +1690,11 @@ void Graph::ascii_save(ostream& o) const { } } } - o << endl; + o << std::endl; } } if (!matrix_form) { - o << "Line Manifest:" << endl; + o << "Line Manifest:" << std::endl; for (i = 0; i < lcnt; ++i) { GraphItem* gi = (GraphItem*) component(i); if (gi->is_polyline()) { @@ -1703,13 +1703,13 @@ void Graph::ascii_save(ostream& o) const { jcnt = gpl->y_data()->count(); if (jcnt && family_label_ && gpl->label()) { o << jcnt << " " << family_label_->text() << "=" << gpl->label()->text() - << endl; + << std::endl; } else { - o << jcnt << endl; + o << jcnt << std::endl; } } } - o << "End of Line Manifest" << endl; + o << "End of Line Manifest" << std::endl; for (i = 0; i < lcnt; ++i) { GraphItem* gi = (GraphItem*) component(i); if (gi->is_polyline()) { @@ -1718,9 +1718,9 @@ void Graph::ascii_save(ostream& o) const { jcnt = gpl->y_data()->count(); if (jcnt && family_label_ && gpl->label()) { o << jcnt << " " << family_label_->text() << "=" << gpl->label()->text() - << endl; + << std::endl; } else { - o << jcnt << endl; + o << jcnt << std::endl; } for (j = 0; j < jcnt; ++j) { o << gpl->x(j) << "\t" << gpl->y(j) << "\n"; @@ -1730,8 +1730,8 @@ void Graph::ascii_save(ostream& o) const { } return; } - o << "Graph addvar/addexpr lines" << endl; - o << lcnt << " " << x_->count() << endl; + o << "Graph addvar/addexpr lines" << std::endl; + o << lcnt << " " << x_->count() << std::endl; if (x_expr_) { o << x_expr_->name; } else { @@ -1740,14 +1740,14 @@ void Graph::ascii_save(ostream& o) const { for (line = 0; line < lcnt; ++line) { o << " " << line_list_.item(line)->name(); } - o << endl; + o << std::endl; dcnt = x_->count(); for (i = 0; i < dcnt; ++i) { o << x_->get_val(i); for (line = 0; line < lcnt; ++line) { o << "\t" << line_list_.item(line)->y(i); } - o << endl; + o << std::endl; } // print the remaining unlabeled polylines. i.e. saved with KeepLines lcnt = count(); @@ -1761,17 +1761,17 @@ void Graph::ascii_save(ostream& o) const { } } } - o << n << " unlabeled lines" << endl; + o << n << " unlabeled lines" << std::endl; for (i = 0; i < lcnt; ++i) { GraphItem* gi = (GraphItem*) component(i); if (gi->is_polyline()) { GPolyLine* gpl = (GPolyLine*) gi->body(); if (!gpl->label()) { int n = gpl->x_data()->count(); - o << n << endl; + o << n << std::endl; int j; for (j = 0; j < n; ++j) { - o << gpl->x(j) << "\t" << gpl->y(j) << endl; + o << gpl->x(j) << "\t" << gpl->y(j) << std::endl; } } } @@ -2412,18 +2412,18 @@ void Graph::see_range_plot(GraphVector* rvp) { Resource::ref(rvp); } -void Graph::save_phase1(ostream& o) { - o << "{" << endl; +void Graph::save_phase1(std::ostream& o) { + o << "{" << std::endl; save_class(o, "Graph"); } static Graph* current_save_graph; -void Graph::save_phase2(ostream& o) { +void Graph::save_phase2(std::ostream& o) { char buf[256]; if (family_label_) { sprintf(buf, "save_window_.family(\"%s\")", family_label_->text()); - o << buf << endl; + o << buf << std::endl; } if (var_name_) { if ((var_name_->string())[var_name_->length() - 1] == '.') { @@ -2431,13 +2431,13 @@ void Graph::save_phase2(ostream& o) { } else { sprintf(buf, "%s = save_window_", var_name_->string()); } - o << buf << endl; + o << buf << std::endl; sprintf(buf, "save_window_.save_name(\"%s\")", var_name_->string()); - o << buf << endl; + o << buf << std::endl; } if (x_expr_) { sprintf(buf, "save_window_.xexpr(\"%s\", %d)", x_expr_->name, x_pval_ ? 1 : 0); - o << buf << endl; + o << buf << std::endl; } long cnt = count(); current_save_graph = this; @@ -2449,7 +2449,7 @@ void Graph::save_phase2(ostream& o) { g->save(o, x, y); } } - o << "}" << endl; + o << "}" << std::endl; } @@ -2755,7 +2755,7 @@ void GraphLine::extension_continue() { extension_->extend(); } -void GraphLine::save(ostream& o) { +void GraphLine::save(std::ostream& o) { char buf[256]; float x, y; if (!label()) { @@ -2786,10 +2786,10 @@ void GraphLine::save(ostream& o) { y, label()->fixtype()); } - o << buf << endl; + o << buf << std::endl; } -void GPolyLine::save(ostream&) {} +void GPolyLine::save(std::ostream&) {} void GPolyLine::label_loc(Coord& x, Coord& y) const { if (label()) { @@ -3077,7 +3077,7 @@ Glyph* GLabel::clone() const { return new GLabel(text_.string(), color_, fixtype_, scale_, x_align_, y_align_); } -void GLabel::save(ostream& o, Coord x, Coord y) { +void GLabel::save(std::ostream& o, Coord x, Coord y) { if (labeled_line()) { return; } @@ -3092,7 +3092,7 @@ void GLabel::save(ostream& o, Coord x, Coord y) { x_align_, y_align_, colors->color(color_)); - o << buf << endl; + o << buf << std::endl; } void GLabel::fixed(float scale) { @@ -3327,10 +3327,10 @@ void DataVec::erase() { void DataVec::write() { #if 0 - cout << get_name() << endl; - cout << count_ << endl; + cout << get_name() << std::endl; + cout << count_ << std::endl; for (int i=0; ierase(); diff --git a/src/ivoc/hocmark.h b/src/ivoc/hocmark.h index d84e3b6f37..65ad5ab0d7 100644 --- a/src/ivoc/hocmark.h +++ b/src/ivoc/hocmark.h @@ -18,7 +18,7 @@ class HocMark: public PolyGlyph { virtual void draw(Canvas*, const Allocation&) const; // virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); - // virtual void save(ostream&); + // virtual void save(std::ostream&); protected: HocMark(char style, float size, const Color*, const Brush*); diff --git a/src/ivoc/idraw.cpp b/src/ivoc/idraw.cpp index bdcd6e4957..39da70660d 100644 --- a/src/ivoc/idraw.cpp +++ b/src/ivoc/idraw.cpp @@ -30,7 +30,7 @@ Coord* OcIdraw::xpath_ = 0; Coord* OcIdraw::ypath_ = 0; void OcIdraw::prologue() { - filebuf ibuf; + std::filebuf ibuf; Style* s = Session::instance()->style(); CopyString name; if (!s->find_attribute("pwm_idraw_prologue", name)) { @@ -40,14 +40,14 @@ void OcIdraw::prologue() { } name = expand_env_var(name.string()); #if defined(WIN32) || defined(MAC) - if (!ibuf.open(name.string(), ios::in)) { + if (!ibuf.open(name.string(), std::ios::in)) { #else if (!ibuf.open(name.string(), IOS_IN)) { #endif printf("can't open the idraw prologue in %s\n", name.string()); return; } - out << &ibuf << endl; + out << &ibuf << std::endl; ibuf.close(); if (!xpath_) { capacity_ = 10; @@ -62,7 +62,7 @@ End %I eop\n\ showpage\n\n\ %%Trailer\n\n\ end\ -" << endl; +" << std::endl; } static void transformer(const Transformer& t) { @@ -70,7 +70,7 @@ static void transformer(const Transformer& t) { t.matrix(a00, a01, a10, a11, a20, a21); char buf[200]; sprintf(buf, "[ %g %g %g %g %g %g ] concat", a00, a01, a10, a11, a20, a21); - out << buf << endl; + out << buf << std::endl; } static char* hidepar(const char* s) { @@ -106,22 +106,22 @@ Begin %I Pict\n\ %I cbg u\n\ %I f u\n\ %I p u\ -" << endl; +" << std::endl; } void OcIdraw::pict() { common_pict(); - out << "%I t u" << endl; + out << "%I t u" << std::endl; } void OcIdraw::pict(const Transformer& t) { common_pict(); - out << "%I t" << endl; + out << "%I t" << std::endl; transformer(t); } void OcIdraw::end() { - out << "End %I eop" << endl; + out << "End %I eop" << std::endl; } void OcIdraw::text(Canvas*, @@ -157,7 +157,7 @@ void OcIdraw::text(Canvas*, Helvetica 12 SetF\n\ "; }; - out << "%I t" << endl; + out << "%I t" << std::endl; Glyph* l = WidgetKit::instance()->label(s); Requisition req; l->request(req); @@ -168,9 +168,9 @@ Helvetica 12 SetF\n\ Transformer tr(t); tr.translate(x, y); transformer(tr); - out << "%I\n[" << endl; - out << "(" << hidepar(s) << ")" << endl; - out << "] Text\nEnd" << endl; + out << "%I\n[" << std::endl; + out << "(" << hidepar(s) << ")" << std::endl; + out << "] Text\nEnd" << std::endl; } void OcIdraw::mline(Canvas*, @@ -247,15 +247,15 @@ void OcIdraw::mline(Canvas*, out << "\nBegin %I MLine\n"; brush(b); ifill(color, false); - out << "%I t" << endl; + out << "%I t" << std::endl; transformer(t); - out << "%I " << size << endl; + out << "%I " << size << std::endl; for (int j = 0; j < size; ++j) { - out << ixd[j] << " " << iyd[j] << endl; + out << ixd[j] << " " << iyd[j] << std::endl; } - out << size << " MLine\n%I 1\nEnd" << endl; + out << size << " MLine\n%I 1\nEnd" << std::endl; } if (count > cnt_group) { @@ -294,7 +294,7 @@ void OcIdraw::polygon(Canvas*, out << "\nBegin %I Poly\n"; poly(count, x, y, color, b, f); sprintf(buf, "%d Poly\nEnd", count); - out << buf << endl; + out << buf << std::endl; } void OcIdraw::bspl(Canvas*, @@ -307,7 +307,7 @@ void OcIdraw::bspl(Canvas*, out << "\nBegin %I BSpl\n"; poly(count, x, y, color, b, false); sprintf(buf, "%d BSpl\n%%I 1\nEnd", count); - out << buf << endl; + out << buf << std::endl; } void OcIdraw::cbspl(Canvas*, @@ -321,7 +321,7 @@ void OcIdraw::cbspl(Canvas*, out << "\nBegin %I CBSpl\n"; poly(count, x, y, color, b, f); sprintf(buf, "%d CBSpl\nEnd", count); - out << buf << endl; + out << buf << std::endl; } void OcIdraw::poly(int count, @@ -332,7 +332,7 @@ void OcIdraw::poly(int count, bool f) { brush(b); ifill(color, f); - out << "%I t" << endl; + out << "%I t" << std::endl; float x1, x2, y1, y2; @@ -355,7 +355,7 @@ void OcIdraw::poly(int count, t.scale(scalex, scaley); t.translate(x1, y1); transformer(t); - out << "%I " << count << endl; + out << "%I " << count << std::endl; char buf[100]; for (int i = 0; i < count; ++i) { float a, b; @@ -375,7 +375,7 @@ void OcIdraw::line(Canvas*, out << "\nBegin %I Line\n"; brush(b); ifill(color, false); - out << "%I t" << endl; + out << "%I t" << std::endl; float scalex, scaley; if (MyMath::eq(x1, x2, .0001f)) { scalex = 1; @@ -391,13 +391,13 @@ void OcIdraw::line(Canvas*, t.scale(scalex, scaley); t.translate(x1, y1); transformer(t); - out << "%I" << endl; + out << "%I" << std::endl; float a, bb, x, y; t.inverse_transform(x1, y1, a, bb); t.inverse_transform(x2, y2, x, y); out << int(a) << " " << int(bb) << " " << int(x) << " " << int(y); - out << " Line\n%I 1\nEnd" << endl; + out << " Line\n%I 1\nEnd" << std::endl; } void OcIdraw::ellipse(Canvas*, @@ -411,7 +411,7 @@ void OcIdraw::ellipse(Canvas*, out << "\nBegin %I Elli\n"; brush(b); ifill(color, f); - out << "%I t" << endl; + out << "%I t" << std::endl; float y = y1; float x = x1; @@ -421,7 +421,7 @@ void OcIdraw::ellipse(Canvas*, transformer(tr); char buf[100]; sprintf(buf, "%%I\n0 0 %d %d Elli\nEnd", int(width * 100), int(height * 100)); - out << buf << endl; + out << buf << std::endl; } void OcIdraw::brush(const Brush* b) { @@ -448,7 +448,7 @@ void OcIdraw::brush(const Brush* b) { } #endif sprintf(buf, "] 0 SetB"); - out << buf << endl; + out << buf << std::endl; } void OcIdraw::ifill(const Color* color, bool f) { @@ -461,7 +461,7 @@ void OcIdraw::ifill(const Color* color, bool f) { // idraw needs hex sprintf( buf, "%%I cfg %x%x%x\n%f %f %f SetCFg", int(r * 256), int(g * 256), int(b * 256), r, g, b); - out << buf << endl; + out << buf << std::endl; if (f) { // sprintf(buf, "%%I cbg %s\n%d %d %d SetCBg\n%%I p\n1 SetP", // "Black", 0,0,0); @@ -476,7 +476,7 @@ void OcIdraw::ifill(const Color* color, bool f) { } else { sprintf(buf, "%%I cbg %s\n%d %d %d SetCBg\nnone SetP %%I p n", "White", 1, 1, 1); } - out << buf << endl; + out << buf << std::endl; } // only implemented for continuous lines, polygons, and curves. diff --git a/src/ivoc/idraw.h b/src/ivoc/idraw.h index 9e6d4142af..9380b3989c 100644 --- a/src/ivoc/idraw.h +++ b/src/ivoc/idraw.h @@ -82,7 +82,7 @@ class OcIdraw { bool fill = false); public: - static ostream* idraw_stream; + static std::ostream* idraw_stream; private: static void rcurve(int level, Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2); diff --git a/src/ivoc/ivoc.h b/src/ivoc/ivoc.h index b589d322d7..bd6cb573b7 100644 --- a/src/ivoc/ivoc.h +++ b/src/ivoc/ivoc.h @@ -10,6 +10,7 @@ #include "gui-redirect.h" extern int nrn_err_dialog_active_; +#include #ifdef MINGW extern bool nrn_is_gui_thread(); @@ -74,7 +75,7 @@ class Oc { static void helpmode(Window*); static void help(const char*); - static ostream* save_stream; + static std::ostream* save_stream; static void cleanup(); private: diff --git a/src/ivoc/ivocmain.cpp b/src/ivoc/ivocmain.cpp index a087521db7..e340f46251 100644 --- a/src/ivoc/ivocmain.cpp +++ b/src/ivoc/ivocmain.cpp @@ -164,7 +164,7 @@ char* nrnpy_pyexe; int Oc::refcnt_ = 0; Session* Oc::session_ = 0; HandleStdin* Oc::handleStdin_ = 0; -ostream* OcIdraw::idraw_stream = 0; +std::ostream* OcIdraw::idraw_stream = 0; #endif /*****************************************************************************/ extern void ivoc_cleanup(); diff --git a/src/ivoc/ocbox.cpp b/src/ivoc/ocbox.cpp index f0fe9d8648..f9e2341e84 100644 --- a/src/ivoc/ocbox.cpp +++ b/src/ivoc/ocbox.cpp @@ -62,7 +62,7 @@ class NrnFixedLayout: public Layout { CopyString* save_action_; Object* save_pyact_; int type_; - ostream* o_; + std::ostream* o_; Object* keep_ref_; CopyString* dis_act_; Object* dis_pyact_; @@ -691,7 +691,7 @@ void OcBox::save_action(const char* creat, Object* pyact) { if (bi_->o_) { // old endl cause great slowness on remote filesystem // with gcc version 3.3 20030226 (prerelease) (SuSE Linux) - //*bi_->o_ << creat << endl; + //*bi_->o_ << creat << std::endl; *bi_->o_ << creat << "\n"; } else { if (pyact) { @@ -728,7 +728,7 @@ void OcBox::dismiss_action(const char* act, Object* pyact) { } } -void OcBox::save(ostream& o) { +void OcBox::save(std::ostream& o) { char buf[256]; if (bi_->save_action_ || bi_->save_pyact_) { if (bi_->save_action_ && strcmp(bi_->save_action_->string(), "") == 0) { @@ -736,9 +736,9 @@ void OcBox::save(ostream& o) { } if (has_window()) { sprintf(buf, "\n//Begin %s", window()->name()); - o << buf << endl; + o << buf << std::endl; } - o << "{" << endl; + o << "{" << std::endl; bi_->o_ = &o; if (bi_->save_pyact_) { HocCommand hc(bi_->save_pyact_); @@ -750,18 +750,18 @@ void OcBox::save(ostream& o) { bi_->o_ = NULL; } else { if (bi_->type_ == H) { - o << "{\nocbox_ = new HBox()" << endl; + o << "{\nocbox_ = new HBox()" << std::endl; } else { - o << "{\nocbox_ = new VBox()" << endl; + o << "{\nocbox_ = new VBox()" << std::endl; } - o << "ocbox_list_.prepend(ocbox_)" << endl; - o << "ocbox_.intercept(1)\n}" << endl; + o << "ocbox_list_.prepend(ocbox_)" << std::endl; + o << "ocbox_.intercept(1)\n}" << std::endl; long i, cnt = bi_->ocglyph_list_->count(); for (i = 0; i < cnt; ++i) { ((OcGlyph*) bi_->ocglyph_list_->component(i))->save(o); } - o << "{\nocbox_ = ocbox_list_.object(0)" << endl; - o << "ocbox_.intercept(0)" << endl; + o << "{\nocbox_ = ocbox_list_.object(0)" << std::endl; + o << "ocbox_.intercept(0)" << std::endl; } if (has_window()) { #if defined(WIN32) @@ -788,19 +788,19 @@ void OcBox::save(ostream& o) { window()->width(), window()->height()); #endif - o << buf << endl; + o << buf << std::endl; } else { - o << "ocbox_.map()\n}" << endl; + o << "ocbox_.map()\n}" << std::endl; } if (bi_->oc_ref_) { sprintf(buf, "%s = ocbox_", hoc_object_pathname(bi_->oc_ref_)); - o << buf << endl; - o << "ocbox_list_.remove(0)" << endl; + o << buf << std::endl; + o << "ocbox_list_.remove(0)" << std::endl; } - o << "objref ocbox_" << endl; + o << "objref ocbox_" << std::endl; if (bi_->save_action_ && has_window()) { sprintf(buf, "//End %s\n", window()->name()); - o << buf << endl; + o << buf << std::endl; } } diff --git a/src/ivoc/ocbox.h b/src/ivoc/ocbox.h index 737341176d..6b633088f9 100644 --- a/src/ivoc/ocbox.h +++ b/src/ivoc/ocbox.h @@ -16,7 +16,7 @@ class OcBox: public OcGlyphContainer { virtual ~OcBox(); virtual void box_append(OcGlyph*); - virtual void save(ostream&); + virtual void save(std::ostream&); virtual void save_action(const char*, Object*); virtual void adjuster(Coord natural); virtual void adjust(Coord natural, int); diff --git a/src/ivoc/ocdeck.cpp b/src/ivoc/ocdeck.cpp index 9a436b5078..1de3bb8757 100644 --- a/src/ivoc/ocdeck.cpp +++ b/src/ivoc/ocdeck.cpp @@ -329,22 +329,22 @@ void OcDeck::save_action(const char* creat, Object* o) { } } -void OcDeck::save(ostream& o) { +void OcDeck::save(std::ostream& o) { char buf[256]; if (bi_->save_action_) { sprintf(buf, "{ocbox_ = %s", bi_->save_action_->string()); - o << buf << endl; + o << buf << std::endl; } else { - o << "{ocbox_ = new Deck()" << endl; - o << "ocbox_list_.prepend(ocbox_)" << endl; - o << "ocbox_.intercept(1)}" << endl; + o << "{ocbox_ = new Deck()" << std::endl; + o << "ocbox_list_.prepend(ocbox_)" << std::endl; + o << "ocbox_.intercept(1)}" << std::endl; long i, cnt = bi_->ocglyph_list_->count(); for (i = 0; i < cnt; ++i) { ((OcGlyph*) bi_->ocglyph_list_->component(i))->save(o); } - o << "{ocbox_ = ocbox_list_.object(0)" << endl; - o << "ocbox_list_.remove(0)" << endl; - o << "ocbox_.intercept(0)" << endl; + o << "{ocbox_ = ocbox_list_.object(0)" << std::endl; + o << "ocbox_list_.remove(0)" << std::endl; + o << "ocbox_.intercept(0)" << std::endl; } if (has_window()) { sprintf(buf, @@ -354,13 +354,13 @@ void OcDeck::save(ostream& o) { window()->save_bottom(), window()->width(), window()->height()); - o << buf << endl; + o << buf << std::endl; } else { - o << "ocbox_.map()}" << endl; + o << "ocbox_.map()}" << std::endl; } if (bi_->oc_ref_) { sprintf(buf, "%s = ocbox_", hoc_object_pathname(bi_->oc_ref_)); - o << buf << endl; + o << buf << std::endl; } } #endif /* HAVE_IV */ diff --git a/src/ivoc/ocdeck.h b/src/ivoc/ocdeck.h index 71e10ba921..873ecc307b 100644 --- a/src/ivoc/ocdeck.h +++ b/src/ivoc/ocdeck.h @@ -13,7 +13,7 @@ class OcDeck: public OcGlyphContainer { virtual ~OcDeck(); virtual void box_append(OcGlyph*); - virtual void save(ostream&); + virtual void save(std::ostream&); virtual void save_action(const char*, Object*); virtual void flip_to(int); virtual void remove_last(); diff --git a/src/ivoc/pwman.cpp b/src/ivoc/pwman.cpp index a21c4394da..a3eee4f57c 100644 --- a/src/ivoc/pwman.cpp +++ b/src/ivoc/pwman.cpp @@ -117,7 +117,7 @@ static bool ivoc_snapshot(const Event*); #define pwm_impl PrintableWindowManager::current()->pwmi_ class HocPanel { public: - static void save_all(ostream&); + static void save_all(std::ostream&); }; int inside(Coord x, Coord y, const Allocation& a) { @@ -179,7 +179,7 @@ bool (*p_java2nrn_identity)(Object* o1, Object* o2); virtual void pmove(int l, int t); virtual void presize(int w, int h); virtual int priority(); - virtual void save_session(const char* fname, ostream& o); + virtual void save_session(const char* fname, std::ostream& o); void ref(); void unref(); Coord l(); @@ -348,10 +348,10 @@ class PaperItem; GlyphIndex upper_left(); void redraw(Window*); bool none_selected(const char*, const char*) const; - void ses_group(ScreenItem* si, ostream& o); + void ses_group(ScreenItem* si, std::ostream& o); int ses_group_first_; - void save_begin(ostream&); - void save_list(int, ScreenItem**, ostream&); + void save_begin(std::ostream&); + void save_list(int, ScreenItem**, std::ostream&); private: StandardWindow* w_; @@ -1879,7 +1879,7 @@ void PWMImpl::do_print_session(bool use_printer, const char* name) { void PWMImpl::ps_file_print(bool use_printer, const char* name, bool land_style, bool ses_style) { Style* s = Session::instance()->style(); static char* tmpfile = (char*) 0; - filebuf obuf; + std::filebuf obuf; #if MAC && !DARWIN obuf.open(name, IOS_OUT); #else @@ -1891,7 +1891,7 @@ void PWMImpl::ps_file_print(bool use_printer, const char* name, bool land_style, #endif obuf.open(tmpfile, IOS_OUT); #endif - ostream o(&obuf); + std::ostream o(&obuf); Printer* pr = new Printer(&o); pr->prolog(); @@ -2813,9 +2813,9 @@ void PWMImpl::file_control() { #if SNAPSHOT void PWMImpl::snapshot(const Event* e) { snap_event_ = e; - filebuf obuf; + std::filebuf obuf; obuf.open(fc_print_->selected()->string(), IOS_OUT); - ostream o(&obuf); + std::ostream o(&obuf); Printer* pr = new Printer(&o); pr->prolog(); pr->resize(0, 0, 1200, 1000); @@ -2962,9 +2962,9 @@ void PWMImpl::idraw_write(const char* fname, bool ses_style) { #ifdef WIN32 unlink(fname); #endif - filebuf obuf; + std::filebuf obuf; obuf.open(fname, IOS_OUT); - ostream o(&obuf); + std::ostream o(&obuf); OcIdraw::idraw_stream = &o; OcIdraw::prologue(); Scene* p = paper(); @@ -3018,12 +3018,12 @@ void PWMImpl::ascii_control() { } void PWMImpl::ascii_write(const char* fname, bool ses_style) { - filebuf obuf; + std::filebuf obuf; #ifdef WIN32 unlink(fname); #endif obuf.open(fname, IOS_OUT); - ostream o(&obuf); + std::ostream o(&obuf); Graph::ascii(&o); Scene* p = paper(); GlyphIndex count = p->count(); @@ -3045,7 +3045,7 @@ void PWMImpl::ascii_write(const char* fname, bool ses_style) { Graph::ascii(NULL); } -ostream* Oc::save_stream; +std::ostream* Oc::save_stream; void PWMImpl::save_selected_control() { save_control(1); @@ -3120,12 +3120,12 @@ int PWMImpl::save_group(Object* ho, const char* filename) { } if (nwin > 0) { cur_ses_name_ = filename; - filebuf obuf; + std::filebuf obuf; #ifdef WIN32 unlink(filename); #endif obuf.open(filename, IOS_OUT); - ostream o(&obuf); + std::ostream o(&obuf); save_begin(o); save_list(nwin, sivec, o); obuf.close(); @@ -3141,7 +3141,7 @@ void PWMImpl::save_session(int mode, const char* filename, const char* head) { ScreenItem* si; ScreenItem** sivec = NULL; - filebuf obuf; + std::filebuf obuf; cur_ses_name_ = filename; #ifdef WIN32 unlink(filename); @@ -3150,9 +3150,9 @@ void PWMImpl::save_session(int mode, const char* filename, const char* head) { if (!obuf.is_open()) { hoc_execerror(filename, "is not open for writing"); } - ostream o(&obuf); + std::ostream o(&obuf); if (head) { - o << head << endl; + o << head << std::endl; } save_begin(o); @@ -3212,15 +3212,15 @@ void PWMImpl::save_session(int mode, const char* filename, const char* head) { } } -void PWMImpl::save_begin(ostream& o) { +void PWMImpl::save_begin(std::ostream& o) { Oc::save_stream = &o; Scene::save_all(o); HocPanel::save_all(o); - o << "objectvar ocbox_, ocbox_list_, scene_, scene_list_" << endl; - o << "{ocbox_list_ = new List() scene_list_ = new List()}" << endl; + o << "objectvar ocbox_, ocbox_list_, scene_, scene_list_" << std::endl; + o << "{ocbox_list_ = new List() scene_list_ = new List()}" << std::endl; } -void PWMImpl::save_list(int nwin, ScreenItem** sivec, ostream& o) { +void PWMImpl::save_list(int nwin, ScreenItem** sivec, std::ostream& o) { // save highest first, only a few priorities OcGlyph* ocg; int i, pri, max, working; @@ -3251,10 +3251,10 @@ void PWMImpl::save_list(int nwin, ScreenItem** sivec, ostream& o) { } } Oc::save_stream = NULL; - o << "objectvar scene_vector_[1]\n{doNotify()}" << endl; + o << "objectvar scene_vector_[1]\n{doNotify()}" << std::endl; } -void PWMImpl::ses_group(ScreenItem* si, ostream& o) { +void PWMImpl::ses_group(ScreenItem* si, std::ostream& o) { char buf[512]; char* name; if (si->group_obj_) { @@ -3304,7 +3304,7 @@ class OcLabelGlyph: public OcGlyph { public: OcLabelGlyph(const char*, OcGlyph*, Glyph*); virtual ~OcLabelGlyph(); - virtual void save(ostream&); + virtual void save(std::ostream&); private: CopyString label_; @@ -3324,12 +3324,12 @@ OcLabelGlyph::~OcLabelGlyph() { Resource::unref(og_); } -void OcLabelGlyph::save(ostream& o) { +void OcLabelGlyph::save(std::ostream& o) { char buf[256]; - o << "{xpanel(\"\")" << endl; + o << "{xpanel(\"\")" << std::endl; sprintf(buf, "xlabel(\"%s\")", label_.string()); - o << buf << endl; - o << "xpanel()}" << endl; + o << buf << std::endl; + o << "xpanel()}" << std::endl; og_->save(o); } @@ -3627,7 +3627,7 @@ int JavaWindow::priority() { return i; } -void JavaWindow::save_session(const char* fname, ostream& o) { +void JavaWindow::save_session(const char* fname, std::ostream& o) { // minimum save is, if ho is not NULL, to // load_java and create an object ocbox_ with the noarg constructor, // which is then unreffed. diff --git a/src/ivoc/scene.cpp b/src/ivoc/scene.cpp index 4c08bad32c..53541241f4 100644 --- a/src/ivoc/scene.cpp +++ b/src/ivoc/scene.cpp @@ -845,16 +845,16 @@ long Scene::scene_list_index(Scene* s) { return -1; } -void Scene::save_all(ostream& o) { +void Scene::save_all(std::ostream& o) { char buf[200]; - o << "objectvar save_window_, rvp_" << endl; + o << "objectvar save_window_, rvp_" << std::endl; if (!scene_list) { return; } long count = scene_list->count(); if (count) { sprintf(buf, "objectvar scene_vector_[%ld]", count); - o << buf << endl; + o << buf << std::endl; } for (long i = 0; i < count; ++i) { Scene* s = scene_list->item(i); @@ -862,10 +862,10 @@ void Scene::save_all(ostream& o) { } } -void Scene::save_class(ostream& o, const char* s) { +void Scene::save_class(std::ostream& o, const char* s) { long count = views_->count(); // PrintableWindow* w = (PrintableWindow*)canvas()->window(); - o << "save_window_ = new " << s << "(0)" << endl; + o << "save_window_ = new " << s << "(0)" << std::endl; char buf[256]; Coord left, top, right, bottom; if (view_count()) { @@ -878,11 +878,11 @@ void Scene::save_class(ostream& o, const char* s) { } sprintf(buf, "save_window_.size(%g,%g,%g,%g)", left, right, bottom, top); - o << buf << endl; + o << buf << std::endl; } -void Scene::save_phase1(ostream&) {} -void Scene::save_phase2(ostream&) {} +void Scene::save_phase1(std::ostream&) {} +void Scene::save_phase2(std::ostream&) {} void Scene::printfile(const char* fname) { if (view_count()) { @@ -891,11 +891,11 @@ void Scene::printfile(const char* fname) { } void XYView::printfile(const char* fname) { - filebuf obuf; + std::filebuf obuf; if (!obuf.open(fname, IOS_OUT)) { return; } - ostream o(&obuf); + std::ostream o(&obuf); EPSPrinter* pr = new EPSPrinter(&o); Allocation a; Allotment ax(0, xsize_, 0); diff --git a/src/ivoc/utility.cpp b/src/ivoc/utility.cpp index bd076e1d6c..53798cd926 100644 --- a/src/ivoc/utility.cpp +++ b/src/ivoc/utility.cpp @@ -141,7 +141,7 @@ static void open_fail(const char* s, Window* w, const char* io) { } bool ok_to_write(const char* s, Window* w) { - filebuf obuf; + std::filebuf obuf; if (obuf.open(s, Input)) { obuf.close(); if (!ok_if_already_exists(s, w)) { @@ -161,7 +161,7 @@ bool ok_to_write(const char* s, Window* w) { } bool ok_to_read(const char* s, Window* w) { - filebuf obuf; + std::filebuf obuf; if (obuf.open(s, Input)) { obuf.close(); errno = 0; diff --git a/src/ivoc/xmenu.cpp b/src/ivoc/xmenu.cpp index 4499836877..79711ad9bb 100644 --- a/src/ivoc/xmenu.cpp +++ b/src/ivoc/xmenu.cpp @@ -950,7 +950,7 @@ static char* hideQuote(const char* s) { static void saveMenuFile() {} -void HocPanel::save_all(ostream&) { +void HocPanel::save_all(std::ostream&) { if (!hoc_panel_list) return; @@ -1195,10 +1195,10 @@ HocPushButton::HocPushButton(const char* name, HocAction* a, HocItem* hi) HocPushButton::~HocPushButton() { Resource::unref(a_); } -void HocPushButton::write(ostream& o) { +void HocPushButton::write(std::ostream& o) { char buf[200]; nrn_assert(snprintf(buf, 200, "xbutton(\"%s\",\"%s\")", getStr(), hideQuote(a_->name())) < 200); - o << buf << endl; + o << buf << std::endl; } #if MAC @@ -1217,11 +1217,11 @@ HocRadioButton::HocRadioButton(const char* name, HocRadioAction* a, HocItem* hi) HocRadioButton::~HocRadioButton() { Resource::unref(a_); } -void HocRadioButton::write(ostream& o) { +void HocRadioButton::write(std::ostream& o) { char buf[200]; nrn_assert(snprintf(buf, 200, "xradiobutton(\"%s\",\"%s\")", getStr(), hideQuote(a_->name())) < 200); - o << buf << endl; + o << buf << std::endl; } #if MAC @@ -1335,10 +1335,10 @@ HocMenu::HocMenu(const char* name, Menu* m, MenuItem* mi, HocItem* hi, bool add2 HocMenu::~HocMenu() { menu_->unref(); } -void HocMenu::write(ostream& o) { +void HocMenu::write(std::ostream& o) { char buf[200]; sprintf(buf, "xmenu(\"%s\", %d)", getStr(), add2menubar_); - o << buf << endl; + o << buf << std::endl; } #if MAC @@ -1436,27 +1436,27 @@ void HocPanel::valueEd(const char* name, last_fe_constructed_ = fe; } -void HocPanel::save(ostream& o) { - o << "{" << endl; +void HocPanel::save(std::ostream& o) { + o << "{" << std::endl; write(o); - o << "}" << endl; + o << "}" << std::endl; } -void HocPanel::write(ostream& o) { +void HocPanel::write(std::ostream& o) { Oc oc; char buf[200]; long i; - // o << "xpanel(\"" << getName() << "\")" << endl; + // o << "xpanel(\"" << getName() << "\")" << std::endl; sprintf(buf, "xpanel(\"%s\", %d)", getName(), horizontal_); - o << buf << endl; + o << buf << std::endl; for (i = 1; i < ilist_.count(); i++) { ilist_.item(i)->write(o); } if (has_window()) { sprintf(buf, "xpanel(%g,%g)", window()->save_left(), window()->save_bottom()); - o << buf << endl; + o << buf << std::endl; } else { - o << "xpanel()" << endl; + o << "xpanel()" << std::endl; } } @@ -1473,8 +1473,8 @@ HocItem::HocItem(const char* str, HocItem* hi) HocItem::~HocItem() { // printf("~HocItem %s\n", str_.string()); } -void HocItem::write(ostream& o) { - o << str_.string() << endl; +void HocItem::write(std::ostream& o) { + o << str_.string() << std::endl; } #if MAC @@ -1523,10 +1523,10 @@ void HocItem::help(const char* child) { HocLabel::HocLabel(const char* s) : HocItem(s) {} HocLabel::~HocLabel() {} -void HocLabel::write(ostream& o) { +void HocLabel::write(std::ostream& o) { char buf[210]; sprintf(buf, "xlabel(\"%s\")", hideQuote(getStr())); - o << buf << endl; + o << buf << std::endl; } #if 0 @@ -1565,13 +1565,13 @@ HocVarLabel::~HocVarLabel() { } } -void HocVarLabel::write(ostream& o) { +void HocVarLabel::write(std::ostream& o) { if (variable_ && cpp_) { char buf[256]; sprintf(buf, "xvarlabel(%s)", variable_->string()); - o << buf << endl; + o << buf << std::endl; } else { - o << "xlabel(\"\")" << endl; + o << "xlabel(\"\")" << std::endl; } } @@ -2109,7 +2109,7 @@ void HocValEditor::updateField() { } } -void HocValEditor::write(ostream& o) { +void HocValEditor::write(std::ostream& o) { char buf[200]; Oc oc; if (variable_) { @@ -2123,7 +2123,7 @@ void HocValEditor::write(ostream& o) { sprintf(buf, "/* variable freed */"); return; } - o << buf << endl; + o << buf << std::endl; int usepointer; if (pval_) { @@ -2140,7 +2140,7 @@ void HocValEditor::write(ostream& o) { hideQuote(action_->name()), (int) canrun_, usepointer) < 200); - o << buf << endl; + o << buf << std::endl; } const char* HocValEditor::variable() const { @@ -2152,15 +2152,15 @@ const char* HocValEditor::variable() const { } -void HocValEditorKeepUpdated::write(ostream& o) { +void HocValEditorKeepUpdated::write(std::ostream& o) { char buf[200]; Oc oc; sprintf(buf, "hoc_ac_ = %s\n", variable()); oc.run(buf); sprintf(buf, "%s = %g", variable(), hoc_ac_); - o << buf << endl; + o << buf << std::endl; sprintf(buf, "xvalue(\"%s\",\"%s\", 2 )", getStr(), variable()); - o << buf << endl; + o << buf << std::endl; } void HocEditorForItem::keystroke(const Event& e) { @@ -2853,7 +2853,7 @@ void OcSlider::data_path(HocDataPaths* hdp, bool append) { } } } -void OcSlider::write(ostream& o) { +void OcSlider::write(std::ostream& o) { if (variable_) { char buf[256]; if (send_) { @@ -2874,7 +2874,7 @@ void OcSlider::write(ostream& o) { vert_, slow_); } - o << buf << endl; + o << buf << std::endl; } } @@ -3022,7 +3022,7 @@ void HocStateButton::data_path(HocDataPaths* hdp, bool append) { } } } -void HocStateButton::write(ostream& o) { +void HocStateButton::write(std::ostream& o) { if (variable_) { char buf[256]; if (style_ == PALETTE) { @@ -3038,7 +3038,7 @@ void HocStateButton::write(ostream& o) { variable_->string(), hideQuote(action_->name())); } - o << buf << endl; + o << buf << std::endl; } } @@ -3181,7 +3181,7 @@ void HocStateMenuItem::data_path(HocDataPaths* hdp, bool append) { } } -void HocStateMenuItem::write(ostream& o) { +void HocStateMenuItem::write(std::ostream& o) { if (variable_) { char buf[256]; sprintf(buf, @@ -3190,7 +3190,7 @@ void HocStateMenuItem::write(ostream& o) { variable_->string(), hideQuote(action_->name())); - o << buf << endl; + o << buf << std::endl; } } diff --git a/src/ivoc/xmenu.h b/src/ivoc/xmenu.h index 7938a68079..533b1a927f 100644 --- a/src/ivoc/xmenu.h +++ b/src/ivoc/xmenu.h @@ -96,8 +96,8 @@ declarePtrList(HocUpdateItemList, HocUpdateItem) declarePtrList(HocItemList, Hoc bool slow = false, Object* pyvar = NULL, Object* pysend = NULL); - virtual void write(ostream&); - virtual void save(ostream&); + virtual void write(std::ostream&); + virtual void save(std::ostream&); virtual HocItem* hoc_item(); void label(const char*); void var_label(char**, Object* pyvar = NULL); @@ -107,7 +107,7 @@ declarePtrList(HocUpdateItemList, HocUpdateItem) declarePtrList(HocItemList, Hoc void notifyHocValue(); void check_valid_pointers(void*, int); Coord left_, bottom_; // write by makeTray read by dissolve - static void save_all(ostream&); + static void save_all(std::ostream&); void data_path(HocDataPaths*, bool); void item_append(HocItem*); #if MAC @@ -137,7 +137,7 @@ class HocItem: public Resource { public: HocItem(const char*, HocItem* parent = NULL); virtual ~HocItem(); - virtual void write(ostream&); + virtual void write(std::ostream&); const char* getStr(); virtual void help(const char* childpath = NULL); virtual void help_parent(HocItem*); @@ -153,7 +153,7 @@ class HocPushButton: public HocItem { public: HocPushButton(const char*, HocAction*, HocItem* parent = NULL); virtual ~HocPushButton(); - virtual void write(ostream&); + virtual void write(std::ostream&); #if MAC virtual int mac_menubar(int&, int, int); #endif @@ -165,7 +165,7 @@ class HocRadioButton: public HocItem { public: HocRadioButton(const char*, HocRadioAction*, HocItem* parent = NULL); virtual ~HocRadioButton(); - virtual void write(ostream&); + virtual void write(std::ostream&); #if MAC virtual int mac_menubar(int&, int, int); #endif @@ -177,7 +177,7 @@ class HocMenu: public HocItem { public: HocMenu(const char*, Menu*, MenuItem*, HocItem* parent = NULL, bool add2menubar = false); virtual ~HocMenu(); - virtual void write(ostream&); + virtual void write(std::ostream&); virtual Menu* menu() { return menu_; } @@ -208,14 +208,14 @@ class HocLabel: public HocItem { public: HocLabel(const char*); virtual ~HocLabel(); - virtual void write(ostream&); + virtual void write(std::ostream&); }; class HocVarLabel: public HocUpdateItem { public: HocVarLabel(char**, PolyGlyph*, Object* pyvar = NULL); virtual ~HocVarLabel(); - virtual void write(ostream&); + virtual void write(std::ostream&); virtual void update_hoc_item(); virtual void check_pointer(void*, int); virtual void data_path(HocDataPaths*, bool); @@ -325,7 +325,7 @@ class HocValEditor: public HocUpdateItem { void evalField(); void audit(); virtual void updateField(); - virtual void write(ostream&); + virtual void write(std::ostream&); virtual void data_path(HocDataPaths*, bool); virtual void check_pointer(void*, int); virtual void print(Printer*, const Allocation&) const; @@ -399,7 +399,7 @@ class HocValEditorKeepUpdated: public HocValEditor { HocItem* parent = NULL, Object* pyvar = NULL); virtual ~HocValEditorKeepUpdated(); - virtual void write(ostream&); + virtual void write(std::ostream&); }; class HocValAction: public HocAction { @@ -443,7 +443,7 @@ class OcSlider: public HocUpdateItem, public Observer { Object* pyvar = NULL, Object* pysend = NULL); virtual ~OcSlider(); - virtual void write(ostream&); + virtual void write(std::ostream&); Adjustable* adjustable(); @@ -481,7 +481,7 @@ class HocStateButton: public HocUpdateItem, public Observer { HocItem* parent = NULL, Object* pyvar = NULL); virtual ~HocStateButton(); - virtual void write(ostream&); + virtual void write(std::ostream&); bool chosen(); void button_action(); @@ -513,7 +513,7 @@ class HocStateMenuItem: public HocUpdateItem, public Observer { HocItem* parent = NULL, Object* pyvar = NULL); virtual ~HocStateMenuItem(); - virtual void write(ostream&); + virtual void write(std::ostream&); bool chosen(); void button_action(); diff --git a/src/ivoc/xyview.cpp b/src/ivoc/xyview.cpp index c5f221badb..063075f237 100644 --- a/src/ivoc/xyview.cpp +++ b/src/ivoc/xyview.cpp @@ -443,7 +443,7 @@ void XYView::zin(Coord& x1, Coord& y1, Coord& x2, Coord& y2) const { y2 -= dy; } -void XYView::save(ostream& o) { +void XYView::save(std::ostream& o) { PrintableWindow* w; if (!canvas_) { if (!parent() || !parent()->has_window()) { @@ -466,7 +466,7 @@ void XYView::save(ostream& o) { w->save_bottom(), xsize_, ysize_); - o << buf << endl; + o << buf << std::endl; } void XYView::scene2view(const Allocation& a) const { @@ -747,7 +747,7 @@ OcViewGlyph::~OcViewGlyph() { Resource::unref(g_); } -void OcViewGlyph::save(ostream& o) { +void OcViewGlyph::save(std::ostream& o) { Scene* s = v_->scene(); char buf[256]; long i = Scene::scene_list_index(s); @@ -757,7 +757,7 @@ void OcViewGlyph::save(ostream& o) { } else { sprintf(buf, "save_window_ = scene_vector_[%ld]", i); } - o << buf << endl; + o << buf << std::endl; v_->save(o); if (!s->mark()) { s->save_phase2(o); diff --git a/src/ivos/ivstream.h b/src/ivos/ivstream.h index c0d96883c0..a8834e11a8 100644 --- a/src/ivos/ivstream.h +++ b/src/ivos/ivstream.h @@ -1,6 +1,4 @@ -#ifndef ivstream_h -#define ivstream_h - +#pragma once #include #include #include @@ -8,5 +6,3 @@ #define IOS_OUT std::ios::out #define IOS_IN std::ios::in #define IOS_APP std::ios::app - -#endif // ivstream_h diff --git a/src/modlunit/units.cpp b/src/modlunit/units.cpp index 6e9a6f2b28..83482d50c4 100644 --- a/src/modlunit/units.cpp +++ b/src/modlunit/units.cpp @@ -1186,12 +1186,10 @@ void nrnunit_dynamic_str(char* buf, const char* name, char* u1, char* u2) { double legacy = dynam_unit_mag(1, u1, u2); double modern = dynam_unit_mag(0, u1, u2); - // TODO: use %a instead of %.18g when translated mechanisms are compiled with - // C++17 instead of C++14 to get an exact hex representation of a double sprintf(buf, "\n" "#define %s _nrnunit_%s[_nrnunit_use_legacy_]\n" - "static double _nrnunit_%s[2] = {%.18g, %g};\n", + "static double _nrnunit_%s[2] = {%a, %g};\n", name, name, name, diff --git a/src/nrniv/nrnmenu.cpp b/src/nrniv/nrnmenu.cpp index d7602c04f9..7fc28ec8ec 100644 --- a/src/nrniv/nrnmenu.cpp +++ b/src/nrniv/nrnmenu.cpp @@ -631,7 +631,7 @@ static double ms_name(void* v) { static double ms_save(void* v) { #if HAVE_IV - ostream* o = Oc::save_stream; + std::ostream* o = Oc::save_stream; if (o) { ((MechanismStandard*) v)->save(gargstr(1), o); } diff --git a/src/nrniv/shape.cpp b/src/nrniv/shape.cpp index 0fc1d88df9..7754b850ed 100644 --- a/src/nrniv/shape.cpp +++ b/src/nrniv/shape.cpp @@ -146,7 +146,7 @@ class OcShapeHandler; } virtual void set_select_action(const char*); virtual void set_select_action(Object*); - virtual void save_phase1(ostream&); + virtual void save_phase1(std::ostream&); virtual PointMark* point_mark(Object*, const Color*, const char style = 'O', @@ -777,8 +777,8 @@ void OcShape::handle_picked() { } } -void OcShape::save_phase1(ostream& o) { - o << "{" << endl; +void OcShape::save_phase1(std::ostream& o) { + o << "{" << std::endl; save_class(o, "Shape"); } @@ -1054,7 +1054,7 @@ void ShapeScene::name(const char* s) { } } -void ShapeScene::save_phase2(ostream& o) { +void ShapeScene::save_phase2(std::ostream& o) { char buf[256]; if (var_name_) { if ((var_name_->string())[var_name_->length() - 1] == '.') { @@ -1062,9 +1062,9 @@ void ShapeScene::save_phase2(ostream& o) { } else { sprintf(buf, "%s = save_window_", var_name_->string()); } - o << buf << endl; + o << buf << std::endl; sprintf(buf, "save_window_.save_name(\"%s\")", var_name_->string()); - o << buf << endl; + o << buf << std::endl; } Graph::save_phase2(o); } diff --git a/src/nrniv/shapeplt.cpp b/src/nrniv/shapeplt.cpp index bfcde71329..801b0f29b4 100644 --- a/src/nrniv/shapeplt.cpp +++ b/src/nrniv/shapeplt.cpp @@ -589,12 +589,12 @@ void ShapePlot::scale(float min, float max) { } -void ShapePlot::save_phase1(ostream& o) { - o << "{" << endl; +void ShapePlot::save_phase1(std::ostream& o) { + o << "{" << std::endl; save_class(o, "PlotShape"); char buf[256]; sprintf(buf, "save_window_.variable(\"%s\")", spi_->sym_->name); - o << buf << endl; + o << buf << std::endl; } void ShapePlot::shape_plot() {} diff --git a/src/nrniv/spaceplt.cpp b/src/nrniv/spaceplt.cpp index 4148171892..2eb3b90534 100644 --- a/src/nrniv/spaceplt.cpp +++ b/src/nrniv/spaceplt.cpp @@ -116,7 +116,7 @@ class RangeVarPlot: public NoIVGraphVector { RangeVarPlot(const char*, Object* pyobj); virtual ~RangeVarPlot(); #if HAVE_IV - virtual void save(ostream&); + virtual void save(std::ostream&); virtual void request(Requisition& req) const; virtual bool choose_sym(Graph*); virtual void update(Observable*); @@ -468,17 +468,17 @@ void RangeVarPlot::request(Requisition& req) const { #endif #if HAVE_IV -void RangeVarPlot::save(ostream& o) { +void RangeVarPlot::save(std::ostream& o) { char buf[256]; - o << "objectvar rvp_" << endl; + o << "objectvar rvp_" << std::endl; sprintf(buf, "rvp_ = new RangeVarPlot(\"%s\")", expr_.string()); - o << buf << endl; + o << buf << std::endl; sprintf(buf, "%s rvp_.begin(%g)", hoc_section_pathname(begin_section_), x_begin_); - o << buf << endl; + o << buf << std::endl; sprintf(buf, "%s rvp_.end(%g)", hoc_section_pathname(end_section_), x_end_); - o << buf << endl; + o << buf << std::endl; sprintf(buf, "rvp_.origin(%g)", origin_); - o << buf << endl; + o << buf << std::endl; Coord x, y; label_loc(x, y); sprintf(buf, @@ -487,7 +487,7 @@ void RangeVarPlot::save(ostream& o) { brushes->brush(brush()), x, y); - o << buf << endl; + o << buf << std::endl; } #endif diff --git a/src/nrnoc/multicore.cpp b/src/nrnoc/multicore.cpp index 73203d03c9..6aa0dc26ff 100644 --- a/src/nrnoc/multicore.cpp +++ b/src/nrnoc/multicore.cpp @@ -83,7 +83,8 @@ using worker_job_t = void* (*) (NrnThread*); // With C++17 and alignment-aware allocators we could do something like // alignas(std::hardware_destructive_interference_size) here and then use a -// regular vector. +// regular vector. https://en.cppreference.com/w/cpp/compiler_support/17 shows +// that std::hardware_destructive_interference_size is not very well supported. struct worker_conf_t { /* for nrn_solve etc.*/ worker_job_t job{};