william@cs.ucla.edu (William Cheng) (02/26/90)
It seems that when a procedure call is invoked, the argument processing is not left-to-right. Is this true for C++? I think InterViews-2.6 code assumes the left-to-right processing of arguments for reading the foreground and background colors of components. I'm using g++-1.36.4 with gcc-1.37 on a SUN3/60 running 4.0.3. Below is a program which reads a character using ReadColor(). SetColors(f,b) sets instance variables 'fg' to f and 'bg' to b. SetColors(ReadColor(),ReadColor()) expects to set 'fg' to the first character and 'bg' to the second character in the input stream. However, we get in backwards. Script follows ... --Bill Cheng -------------------------------------------------------------------------------- Script started on Sun Feb 25 16:02:45 1990 {rye:william}[1] cdiv {rye:william}[2] cd src/bin/test-programs/SUN3 {rye:william}[3] cat ../two-reads.c #include <stdio.h> #include <stream.h> class SF_Rect { public: char ReadColor(); void SetColors(char f, char b); char buf[20], fg[10], bg[10]; }; char SF_Rect::ReadColor() { cin >> buf; return (buf[0]); } void SF_Rect::SetColors(char f, char b) { fg[0] = f; fg[1] = '\0'; bg[0] = b; bg[1] = '\0'; } main () { SF_Rect* rect = new SF_Rect; rect->SetColors(rect->ReadColor(), rect->ReadColor()); // Calls the 2nd one // first! cout << rect->fg << "\n"; cout << rect->bg << "\n"; } {rye:william}[4] make two-reads compiling ../two-reads.c rm -f two-reads.o g++ -c -g -v -I.. -I../Generated -I../../../.././src/InterViews/Std -I../../../.././src -I../../../.././installed/lib/SUN3/gcc-include ../two-reads.c g++ version 1.36.4 (based on GCC 1.37) /u/tangram/X11/InterViews/iv/installed/lib/SUN3/gcc-cpp -+ -v -I.. -I../Generated -I../../../.././src/InterViews/Std -I../../../.././src -I../../../.././installed/lib/SUN3/gcc-include -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 ../two-reads.c /usr/tmp/cca07895.cpp GNU CPP version 1.37 /u/tangram/X11/InterViews/iv/installed/lib/SUN3/gcc-cc1plus /usr/tmp/cca07895.cpp -quiet -dumpbase ../two-reads.c -g -version -o /usr/tmp/cca07895.s GNU C++ version 1.36.4 (based on GCC 1.37) (68k, MIT syntax) compiled by GNU C version 1.37. default target switches: -m68020 -mc68020 -m68881 -mbitfield /u/tangram/X11/InterViews/iv/installed/lib/SUN3/gcc-as -mc68020 -o two-reads.o /usr/tmp/cca07895.s linking two-reads g++ -o two-reads two-reads.o ../../../.././src/libInterViews/SUN3/libInterViewsX11.a -g -v -lX11 -lm g++ version 1.36.4 (based on GCC 1.37) /u/tangram/X11/InterViews/iv/installed/lib/SUN3/gcc-ld -o two-reads -e start -dc -dp -Bstatic /lib/crt0.o /lib/Mcrt1.o two-reads.o ../../../.././src/libInterViews/SUN3/libInterViewsX11.a -lX11 -lm -lg++ /u/tangram/X11/InterViews/iv/installed/lib/SUN3/gcc-gnulib -lg -lc -lg -L/usr/lib/f68881 {rye:william}[5] two-reads b w w b {rye:william}[6] ^D script done on Sun Feb 25 16:05:49 1990 -- Bill Cheng // UCLA Computer Science Department // (213) 206-7135 3277 Boelter Hall // Los Angeles, California 90024 // USA william@CS.UCLA.EDU ...!{uunet|ucbvax}!cs.ucla.edu!william