From 9cc09b85136ed7e36b24e74243f3acedeaeb0612 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 4 Nov 2021 17:02:07 +0000 Subject: [PATCH] Remove "using namespace std" from vvp header files and fix the fallout. --- tgt-vvp/vvp_config.h.in | 8 -------- vvp/arith.cc | 2 ++ vvp/array.cc | 2 ++ vvp/compile.h | 8 +++----- vvp/concat.cc | 3 ++- vvp/config.h.in | 8 -------- vvp/delay.cc | 4 +++- vvp/enum_type.cc | 4 +++- vvp/main.cc | 2 ++ vvp/parse.y | 4 +++- vvp/part.cc | 4 +++- vvp/resolv.cc | 3 ++- vvp/schedule.cc | 2 ++ vvp/udp.cc | 4 +++- vvp/udp.h | 4 ++-- vvp/vpi_callback.cc | 3 +++ vvp/vpi_vthr_vector.cc | 2 ++ vvp/vvp_darray.h | 4 ++-- vvp/vvp_island.cc | 4 +++- vvp/vvp_net.cc | 4 +++- vvp/vvp_net.h | 17 +++++++---------- vvp/vvp_net_sig.h | 6 ++---- vvp/words.cc | 4 +++- 23 files changed, 57 insertions(+), 49 deletions(-) diff --git a/tgt-vvp/vvp_config.h.in b/tgt-vvp/vvp_config.h.in index 0644e7e74..7872fa116 100644 --- a/tgt-vvp/vvp_config.h.in +++ b/tgt-vvp/vvp_config.h.in @@ -19,14 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if defined(__cplusplus) -# if !defined(__GNUC__) - using namespace std; -# elif (__GNUC__ == 3) - using namespace std; -# endif -#endif - # undef HAVE_STDINT_H # undef HAVE_INTTYPES_H diff --git a/vvp/arith.cc b/vvp/arith.cc index 092a5c583..b1b80e5b5 100644 --- a/vvp/arith.cc +++ b/vvp/arith.cc @@ -25,6 +25,8 @@ # include # include +using namespace std; + vvp_arith_::vvp_arith_(unsigned wid) : wid_(wid), op_a_(wid), op_b_(wid), x_val_(wid) { diff --git a/vvp/array.cc b/vvp/array.cc index 0fea91c4a..48848b52e 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -36,6 +36,8 @@ # include # include "ivl_alloc.h" +using namespace std; + unsigned long count_net_arrays = 0; unsigned long count_net_array_words = 0; unsigned long count_var_arrays = 0; diff --git a/vvp/compile.h b/vvp/compile.h index ba62b9220..76befa6d6 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -1,7 +1,7 @@ #ifndef IVL_compile_H #define IVL_compile_H /* - * Copyright (c) 2001-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -27,13 +27,11 @@ # include "sv_vpi_user.h" # include "vvp_net.h" -using namespace std; - /* * The file names are kept in this vector. Entry 0 is "N/A" and 1 is * for interactive commands. */ -extern vector file_names; +extern std::vector file_names; /* * The functions described here are the compile time support @@ -54,7 +52,7 @@ extern bool verbose_flag; * If this file opened, then write debug information to this * file. This is used for debugging the VVP runtime itself. */ -extern ofstream debug_file; +extern std::ofstream debug_file; /* * Connect a list of symbols to a contiguous set of ipoints. diff --git a/vvp/concat.cc b/vvp/concat.cc index b16d6a615..462ece46a 100644 --- a/vvp/concat.cc +++ b/vvp/concat.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -23,6 +23,7 @@ # include # include +using namespace std; vvp_fun_concat::vvp_fun_concat(unsigned w0, unsigned w1, unsigned w2, unsigned w3) diff --git a/vvp/config.h.in b/vvp/config.h.in index ee5862707..981907ecf 100644 --- a/vvp/config.h.in +++ b/vvp/config.h.in @@ -19,14 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if defined(__cplusplus) -# if !defined(__GNUC__) - using namespace std; -# elif (__GNUC__ == 3) - using namespace std; -# endif -#endif - # define SIZEOF_UNSIGNED_LONG_LONG 0 #ifndef SIZEOF_UNSIGNED_LONG # define SIZEOF_UNSIGNED_LONG 0 diff --git a/vvp/delay.cc b/vvp/delay.cc index fb10b2408..748317e5d 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2020 Stephen Williams + * Copyright (c) 2005-2021 Stephen Williams * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -31,6 +31,8 @@ #include #include "ivl_alloc.h" +using namespace std; + void vvp_delay_t::calculate_min_delay_() { min_delay_ = rise_; diff --git a/vvp/enum_type.cc b/vvp/enum_type.cc index 274a129ce..155e948f8 100644 --- a/vvp/enum_type.cc +++ b/vvp/enum_type.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2010-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -25,6 +25,8 @@ # include # include +using namespace std; + struct enumconst_s : public __vpiHandle { enumconst_s(); int get_type_code(void) const; diff --git a/vvp/main.cc b/vvp/main.cc index 034354e94..83e0e8308 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -49,6 +49,8 @@ const char COPYRIGHT[] = # include #endif +using namespace std; + ofstream debug_file; #if defined(__MINGW32__) && !defined(HAVE_GETOPT_H) diff --git a/vvp/parse.y b/vvp/parse.y index 93734f4c4..5ac94bdf5 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -1,7 +1,7 @@ %{ /* - * Copyright (c) 2001-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-202` Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -29,6 +29,8 @@ # include "ivl_alloc.h" # include "version_base.h" +using namespace std; + /* * These are bits in the lexor. */ diff --git a/vvp/part.cc b/vvp/part.cc index 55c212cba..54df4c122 100644 --- a/vvp/part.cc +++ b/vvp/part.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2016 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -26,6 +26,8 @@ # include # include +using namespace std; + struct vvp_fun_part_state_s { vvp_fun_part_state_s() : bitsr(0.0) {} diff --git a/vvp/resolv.cc b/vvp/resolv.cc index cd6bfa9e6..7742f700f 100644 --- a/vvp/resolv.cc +++ b/vvp/resolv.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -25,6 +25,7 @@ # include # include +using namespace std; /* * The core functor for a resolver node stores all the input values diff --git a/vvp/schedule.cc b/vvp/schedule.cc index 8a0f04091..603437adc 100644 --- a/vvp/schedule.cc +++ b/vvp/schedule.cc @@ -35,6 +35,8 @@ # include "ivl_alloc.h" #endif +using namespace std; + unsigned long count_assign_events = 0; unsigned long count_gen_events = 0; unsigned long count_thread_events = 0; diff --git a/vvp/udp.cc b/vvp/udp.cc index d5775fcc7..c304f5176 100644 --- a/vvp/udp.cc +++ b/vvp/udp.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2019 Stephen Williams (steve@icarus.com) + * Copyright (c) 2005-2021 Stephen Williams (steve@icarus.com) * * (This is a rewrite of code that was ... * Copyright (c) 2001 Stephan Boettcher ) @@ -35,6 +35,8 @@ #include "ivl_alloc.h" #endif +using namespace std; + // We may need these later when we build the VPI interface to // UDP definitions. #ifdef CHECK_WITH_VALGRIND diff --git a/vvp/udp.h b/vvp/udp.h index dedea300b..758adfc67 100644 --- a/vvp/udp.h +++ b/vvp/udp.h @@ -1,7 +1,7 @@ #ifndef IVL_udp_H #define IVL_udp_H /* - * Copyright (c) 2005-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2005-2021 Stephen Williams (steve@icarus.com) * * (This is a rewrite of code that was ... * Copyright (c) 2001 Stephan Boettcher ) @@ -109,7 +109,7 @@ struct udp_levels_table { unsigned long mask1; unsigned long maskx; }; -extern ostream& operator<< (ostream&o, const struct udp_levels_table&t); +extern std::ostream& operator<< (std::ostream&o, const struct udp_levels_table&t); class vvp_udp_comb_s : public vvp_udp_s { diff --git a/vvp/vpi_callback.cc b/vvp/vpi_callback.cc index 0c9a38d92..89917d555 100644 --- a/vvp/vpi_callback.cc +++ b/vvp/vpi_callback.cc @@ -37,6 +37,9 @@ # include # include # include + +using namespace std; + /* * Callback handles are created when the VPI function registers a * callback. The handle is stored by the run time, and it triggered diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index 57ece0e5d..69919fa30 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -35,6 +35,8 @@ # include # include "ivl_alloc.h" +using namespace std; + /* * Hex digits that represent 4-value bits of Verilog are not as * trivially obvious to display as if the bits were the usual 2-value diff --git a/vvp/vvp_darray.h b/vvp/vvp_darray.h index e846f05a5..f51c9bacb 100644 --- a/vvp/vvp_darray.h +++ b/vvp/vvp_darray.h @@ -1,7 +1,7 @@ #ifndef IVL_vvp_darray_H #define IVL_vvp_darray_H /* - * Copyright (c) 2012-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -247,6 +247,6 @@ class vvp_queue_vec4 : public vvp_queue { std::deque queue; }; -extern string get_fileline(); +extern std::string get_fileline(); #endif /* IVL_vvp_darray_H */ diff --git a/vvp/vvp_island.cc b/vvp/vvp_island.cc index 21e8c4b01..f0aa6d352 100644 --- a/vvp/vvp_island.cc +++ b/vvp/vvp_island.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -32,6 +32,8 @@ # include # include "ivl_alloc.h" +using namespace std; + static bool at_EOS = false; void island_send_value(vvp_net_t*net, const vvp_vector8_t&val) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index f549d6e9b..c06823f3d 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -41,6 +41,8 @@ # include "ivl_alloc.h" #endif +using namespace std; + /* This is the size of an unsigned long in bits. This is just a convenience macro. */ # define CPU_WORD_BITS (8*sizeof(unsigned long)) diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index a243df5e5..41eab1e10 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -34,14 +34,11 @@ #ifdef HAVE_IOSFWD # include #else -class ostream; +# include #endif # include "ivl_alloc.h" -using namespace std; - - /* Data types */ class vvp_scalar_t; @@ -186,7 +183,7 @@ inline vvp_bit4_t operator & (vvp_bit4_t a, vvp_bit4_t b) extern vvp_bit4_t operator ^ (vvp_bit4_t a, vvp_bit4_t b); -extern ostream& operator<< (ostream&o, vvp_bit4_t a); +extern std::ostream& operator<< (std::ostream&o, vvp_bit4_t a); /* Return >0, ==0 or <0 if the from-to transition represents a posedge, no edge, or negedge. */ @@ -529,7 +526,7 @@ inline vvp_vector4_t operator ~ (const vvp_vector4_t&that) return res; } -extern ostream& operator << (ostream&, const vvp_vector4_t&); +extern std::ostream& operator << (std::ostream&, const vvp_vector4_t&); extern vvp_bit4_t compare_gtge(const vvp_vector4_t&a, const vvp_vector4_t&b, @@ -739,7 +736,7 @@ extern vvp_vector4_t c4string_to_vector4(const char*str); extern bool crstring_test(const char*str); extern double crstring_to_double(const char*str); -extern ostream& operator<< (ostream&, const vvp_vector2_t&); +extern std::ostream& operator<< (std::ostream&, const vvp_vector2_t&); inline vvp_vector2_t::vvp_vector2_t(const vvp_vector2_t&that) { @@ -892,7 +889,7 @@ inline vvp_scalar_t resolve(vvp_scalar_t a, vvp_scalar_t b) return fully_featured_resolv_(a,b); } -extern ostream& operator<< (ostream&, vvp_scalar_t); +extern std::ostream& operator<< (std::ostream&, vvp_scalar_t); /* * This class is a way to carry vectors of strength modeled @@ -976,7 +973,7 @@ extern bool c8string_test(const char*str); extern vvp_vector8_t c8string_to_vector8(const char*str); /* Print a vector8 value to a stream. */ -extern ostream& operator<< (ostream&, const vvp_vector8_t&); +extern std::ostream& operator<< (std::ostream&, const vvp_vector8_t&); inline vvp_vector8_t::vvp_vector8_t(unsigned size__) : size_(size__) @@ -1075,7 +1072,7 @@ template class vvp_sub_pointer_t { }; typedef vvp_sub_pointer_t vvp_net_ptr_t; -template ostream& operator << (ostream&out, vvp_sub_pointer_t val) +template std::ostream& operator << (std::ostream&out, vvp_sub_pointer_t val) { out << val.ptr() << "[" << val.port() << "]"; return out; } /* diff --git a/vvp/vvp_net_sig.h b/vvp/vvp_net_sig.h index 161503d6a..8fa28e03f 100644 --- a/vvp/vvp_net_sig.h +++ b/vvp/vvp_net_sig.h @@ -1,7 +1,7 @@ #ifndef IVL_vvp_net_sig_H #define IVL_vvp_net_sig_H /* - * Copyright (c) 2004-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -33,11 +33,9 @@ #ifdef HAVE_IOSFWD # include #else -class ostream; +# include #endif -using namespace std; - /* vvp_fun_signal * This node is the place holder in a vvp network for signals, * including nets of various sort. The output from a signal follows diff --git a/vvp/words.cc b/vvp/words.cc index f0a79bcaa..4257065dc 100644 --- a/vvp/words.cc +++ b/vvp/words.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -32,6 +32,8 @@ # include # include +using namespace std; + static void __compile_var_real(char*label, char*name, vvp_array_t array, unsigned long array_addr) {