Re: Build failure with version 2007-08-20

David Fang <[email protected]>
Newsgroups gmane.comp.gnu.gnucap.devel
Message-ID <[email protected]>
>> if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../src  -DNDEBUG  -g -O2 -MT
>> mg_out_dev.o -MD -MP -MF ".deps/mg_out_dev.Tpo" -c -o mg_out_dev.o
>> mg_out_dev.cc; \
>> then mv -f ".deps/mg_out_dev.Tpo" ".deps/mg_out_dev.Po"; else rm -f
>> ".deps/mg_out_dev.Tpo"; exit 1; fi
>> mg_out_dev.cc: In function `std::string fix_expression(const
>> std::string&)':
>> mg_out_dev.cc:336: error: type specifier omitted for parameter `in'
>
> Hi,
>
> I can reproduce this with all the g++-3.3 compilers I've tried, it seems to 
> be an old parser bug that interprets
>
> 	CS x(CS_STRING(), in);
>
> as a function declaration.

Try this patch (attached), which addresses the same problem in other 
files.

in "ap.h", if you use the "extern const" variant of the path, you'll 
probably want to define those _CS_* objects in some translation unit, if 
you don't want to assume that references to them will be optimized away.

BTW, src/ap.h and modelgen/ap.h are identical (same patch applied to 
both), and since modelgen builds with -I $(top_srcdir)/src, modelgen's 
copy can probably be removed to avoid confusion.

David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/
 	-- (2400 baud? Netscape 3.0?? lynx??? No problem!)

_______________________________________________
Gnucap-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnucap-devel
gnucap-2007-08-20.patch (text/plain, 8.3 KB)
diff -r -u gnucap-2007-08-20-orig/modelgen/ap.h gnucap-2007-08-20/modelgen/ap.h
--- gnucap-2007-08-20-orig/modelgen/ap.h	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/modelgen/ap.h	2007-08-25 16:45:09.000000000 -0400
@@ -43,6 +43,18 @@
 class CS_WHOLE_FILE {};
 class CS_STRING {};
 
+#if 0
+extern const CS_STDIN		_CS_STDIN;
+extern const CS_INC_FILE	_CS_INC_FILE;
+extern const CS_WHOLE_FILE	_CS_WHOLE_FILE;
+extern const CS_STRING		_CS_STRING;
+#else
+static const CS_STDIN		_CS_STDIN = CS_STDIN();
+static const CS_INC_FILE	_CS_INC_FILE = CS_INC_FILE();
+static const CS_WHOLE_FILE	_CS_WHOLE_FILE = CS_WHOLE_FILE();
+static const CS_STRING		_CS_STRING = CS_STRING();
+#endif
+
 class CS {
 private:
   FILE* _file;
diff -r -u gnucap-2007-08-20-orig/modelgen/mg_out_dev.cc gnucap-2007-08-20/modelgen/mg_out_dev.cc
--- gnucap-2007-08-20-orig/modelgen/mg_out_dev.cc	2007-08-20 13:41:16.000000000 -0400
+++ gnucap-2007-08-20/modelgen/mg_out_dev.cc	2007-08-25 16:37:52.000000000 -0400
@@ -333,7 +333,7 @@
   std::string out;
   out[0] = '\0';
   
-  CS x(CS_STRING(), in);
+  CS x(_CS_STRING, in);
   for (;;) {
     if (x.peek() == '@') {
       x.skip1('@');
diff -r -u gnucap-2007-08-20-orig/src/ap.h gnucap-2007-08-20/src/ap.h
--- gnucap-2007-08-20-orig/src/ap.h	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/ap.h	2007-08-25 16:37:47.000000000 -0400
@@ -43,6 +43,18 @@
 class CS_WHOLE_FILE {};
 class CS_STRING {};
 
+#if 0
+extern const CS_STDIN		_CS_STDIN;
+extern const CS_INC_FILE	_CS_INC_FILE;
+extern const CS_WHOLE_FILE	_CS_WHOLE_FILE;
+extern const CS_STRING		_CS_STRING;
+#else
+static const CS_STDIN		_CS_STDIN = CS_STDIN();
+static const CS_INC_FILE	_CS_INC_FILE = CS_INC_FILE();
+static const CS_WHOLE_FILE	_CS_WHOLE_FILE = CS_WHOLE_FILE();
+static const CS_STRING		_CS_STRING = CS_STRING();
+#endif
+
 class CS {
 private:
   FILE* _file;
diff -r -u gnucap-2007-08-20-orig/src/bm_model.cc gnucap-2007-08-20/src/bm_model.cc
--- gnucap-2007-08-20-orig/src/bm_model.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/bm_model.cc	2007-08-25 18:04:42.000000000 -0400
@@ -94,7 +94,7 @@
   }
 
   c->set_modelname(modelname());
-  CS args(CS_STRING(), _arglist); //obsolete_callback
+  CS args(_CS_STRING, _arglist); //obsolete_callback
   c->parse_common_obsolete_callback(args); //BUG//callback
   c->elabo3(d);
   attach_common(c, &_func);
diff -r -u gnucap-2007-08-20-orig/src/c__cmd.cc gnucap-2007-08-20/src/c__cmd.cc
--- gnucap-2007-08-20-orig/src/c__cmd.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/c__cmd.cc	2007-08-25 18:05:01.000000000 -0400
@@ -109,7 +109,7 @@
 /*--------------------------------------------------------------------------*/
 void CMD::command(const std::string& cs, CARD_LIST* scope)
 {
-  CS cmd(CS_STRING(), cs); // from string, full command
+  CS cmd(_CS_STRING, cs); // from string, full command
   std::string s;
   cmd >> s;
   notstd::to_lower(&s);
diff -r -u gnucap-2007-08-20-orig/src/c_sweep.cc gnucap-2007-08-20/src/c_sweep.cc
--- gnucap-2007-08-20-orig/src/c_sweep.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/c_sweep.cc	2007-08-25 17:31:39.000000000 -0400
@@ -100,7 +100,7 @@
     char buffer[BUFLEN];
     fgets(buffer,BUFLEN,fptr);
     {
-      CS cmd(CS_STRING(), buffer); //fgets from local file, obsolete
+      CS cmd(_CS_STRING, buffer); //fgets from local file, obsolete
       if (cmd.pmatch("SWeep")) {
 	setup(cmd);
       }else{
@@ -112,7 +112,7 @@
     }					/* in case the words run together   */
     for (;;) {				/* may wipe out one letter of fault */
       {
-	CS cmd(CS_STRING(), buffer); //fgets from local file, obsolete
+	CS cmd(_CS_STRING, buffer); //fgets from local file, obsolete
 	CMD::cmdproc(cmd, scope);
       }
       if (!fgets(buffer,BUFLEN,fptr)) {
@@ -120,7 +120,7 @@
       }else{
       }
       {
-	CS cmd(CS_STRING(), buffer); //fgets from local file, obsolete
+	CS cmd(_CS_STRING, buffer); //fgets from local file, obsolete
 	if (cmd.pmatch("SWeep")) {
 	  cmd.warn(bDANGER, "command not allowed in sweep");
 	  buffer[0] = '\'';
diff -r -u gnucap-2007-08-20-orig/src/d_subckt.cc gnucap-2007-08-20/src/d_subckt.cc
--- gnucap-2007-08-20-orig/src/d_subckt.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/d_subckt.cc	2007-08-25 17:42:10.000000000 -0400
@@ -173,7 +173,7 @@
 /*--------------------------------------------------------------------------*/
 double DEV_SUBCKT::tr_probe_num(const std::string& x)const
 {itested();
-  CS cmd(CS_STRING(), x); // "", conversion
+  CS cmd(_CS_STRING, x); // "", conversion
   if (cmd.pmatch("V")) {itested();
     int nn = cmd.ctoi();
     return (nn > 0 && nn <= net_nodes()) ? _n[nn-1].v0() : NOT_VALID;
diff -r -u gnucap-2007-08-20-orig/src/e_compon.cc gnucap-2007-08-20/src/e_compon.cc
--- gnucap-2007-08-20-orig/src/e_compon.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/e_compon.cc	2007-08-25 17:42:51.000000000 -0400
@@ -311,7 +311,7 @@
 {itested();
   if (has_parse_params_obsolete_callback()) {
     std::string args(name + "=" + value);
-    CS cmd(CS_STRING(), args); //obsolete_callback
+    CS cmd(_CS_STRING, args); //obsolete_callback
     bool ok = parse_params_obsolete_callback(cmd); //BUG//callback
     if (!ok) {
       throw Exception_No_Match();
diff -r -u gnucap-2007-08-20-orig/src/findbr.cc gnucap-2007-08-20/src/findbr.cc
--- gnucap-2007-08-20-orig/src/findbr.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/findbr.cc	2007-08-25 17:43:02.000000000 -0400
@@ -75,7 +75,7 @@
 	if ((**here).subckt()) {untested();
 	  untested();
 	  // has a subckt, and its name matches, doing fine
-	  CS want(CS_STRING(), local_part); // recursion
+	  CS want(_CS_STRING, local_part); // recursion
 	  CARD_LIST::fat_iterator subbrh=findbranch(want,(**here).subckt());
 	  if (!subbrh.is_end()) {untested();
 	    // found it in a subckt
diff -r -u gnucap-2007-08-20-orig/src/l_pmatch.cc gnucap-2007-08-20/src/l_pmatch.cc
--- gnucap-2007-08-20-orig/src/l_pmatch.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/l_pmatch.cc	2007-08-25 17:43:15.000000000 -0400
@@ -46,7 +46,7 @@
  */
 int pmatch(const std::string& str1, const std::string& str2)
 {
-  CS cmd(CS_STRING(), str1); //call to CS member on string
+  CS cmd(_CS_STRING, str1); //call to CS member on string
   if (cmd.pmatch(str2)) {
     return cmd.cursor();
   }else{
diff -r -u gnucap-2007-08-20-orig/src/lang_spice_commands.cc gnucap-2007-08-20/src/lang_spice_commands.cc
--- gnucap-2007-08-20-orig/src/lang_spice_commands.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/lang_spice_commands.cc	2007-08-25 17:43:27.000000000 -0400
@@ -138,7 +138,7 @@
   }while (cmd.more() && !cmd.stuck(&here));
   cmd.check(bWARNING, "need echo, list, or quiet");
 
-  CS file(CS_INC_FILE(), file_name);
+  CS file(_CS_INC_FILE, file_name);
 
   if (skip_header) { // get and store the header line
     file.get_line(">>>>");
diff -r -u gnucap-2007-08-20-orig/src/main.cc gnucap-2007-08-20/src/main.cc
--- gnucap-2007-08-20-orig/src/main.cc	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/main.cc	2007-08-25 17:43:40.000000000 -0400
@@ -62,7 +62,7 @@
   }
   {
     SET_RUN_MODE xx(rINTERACTIVE);
-    CS cmd(CS_STDIN(), "");
+    CS cmd(_CS_STDIN, "");
     for (;;) {itested();
       if (!sigsetjmp(env.p, true)) {itested();
 	//try {
@@ -118,7 +118,7 @@
     }else if (strcasecmp(argv[ii], "-c") == 0) {untested();
       ++ii;
       if (ii < argc) {untested();
-	CS cmd(CS_STRING(), argv[ii++]); // command line
+	CS cmd(_CS_STRING, argv[ii++]); // command line
 	CMD::cmdproc(cmd, &CARD_LIST::card_list); 
       }else{untested();
       }
diff -r -u gnucap-2007-08-20-orig/src/u_parameter.h gnucap-2007-08-20/src/u_parameter.h
--- gnucap-2007-08-20-orig/src/u_parameter.h	2007-08-20 13:41:49.000000000 -0400
+++ gnucap-2007-08-20/src/u_parameter.h	2007-08-25 16:32:34.000000000 -0400
@@ -68,7 +68,7 @@
   //void	operator=(const std::string& s)	{untested();_s = s;}
 
   void	operator=(const std::string& s)	{
-    CS cmd(CS_STRING(), s); // conversion
+    CS cmd(_CS_STRING, s); // conversion
     parse(cmd);
     //assert(!cmd.more()); // can fail when assigning float to int
   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.