home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / g / help / 1623 < prev    next >
Encoding:
Text File  |  1993-01-02  |  2.0 KB  |  70 lines

  1. Xref: sparky gnu.g++.help:1623 comp.lang.c++:18644
  2. Newsgroups: gnu.g++.help,comp.lang.c++
  3. Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!idiap.CH!tmb
  4. From: tmb@idiap.CH (Thomas M. Breuel)
  5. Subject: gcc (C++) 2.3.2 generates bad assembly language output (redefined 
  6.          symbol)
  7. Message-ID: <9301021848.AA15972@idiap.ch>
  8. Sender: gnulists@ai.mit.edu
  9. Reply-To: tmb@idiap.ch
  10. Organization: Gatewayed from the GNU Project mailing list help-g++@prep.ai.mit.edu
  11. Date: Sat, 2 Jan 1993 20:48:51 GMT
  12. Lines: 56
  13.  
  14. gcc -v -c foo.cc
  15. Reading specs from /sym/gnu/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/specs
  16. gcc version 2.3.2
  17.  /sym/gnu/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix foo.cc /local/tmp/cca11717.i
  18. GNU CPP version 2.3.2 (sparc)
  19.  /sym/gnu/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/cc1plus /local/tmp/cca11717.i -quiet -dumpbase foo.cc -version -o /local/tmp/cca11717.s
  20. GNU C++ version 2.3.2 (sparc) compiled by GNU C version 2.3.2.
  21.  as -o foo.o /local/tmp/cca11717.s
  22. as: "/local/tmp/cca11717.s", line 96: error: redefinition of symbol "_lookup"
  23. gcc: foo.o: No such file or directory
  24.  
  25. == foo.cc ======================================================
  26. #include <std.h>
  27.  
  28. template <class Y>
  29. struct NameValuePair {
  30.     char *name;
  31.     Y y;
  32. };
  33.  
  34. template <class Y>
  35. inline Y lookup(NameValuePair<Y> *data,char *name) {
  36.     while(data->name) {
  37.         if(!strcmp(data->name,name)) return data->y;
  38.         data++;
  39.     }
  40.     abort();
  41.     return data->y;        // to keep GCC happy
  42. }
  43.  
  44. template <class T>
  45. void swap(T &x,T &y) {
  46.     T temp = x;
  47.     x = y;
  48.     y = temp;
  49. }
  50.  
  51. typedef char (*canonicalizer)(char &,float *);
  52.  
  53. NameValuePair<canonicalizer> canonicalizers[] = {
  54.     {0,0}
  55. };
  56.  
  57. typedef float (*extractor)(float &image,float g=2.0);
  58.  
  59. NameValuePair<extractor> extractors[] = {
  60.     {0,0}
  61. };
  62.  
  63. void foo() {
  64.     canonicalizer canonicalize = lookup(canonicalizers,(char*)"foo");
  65.     extractor extract = lookup(extractors,(char*)"bar");
  66. }
  67.  
  68. ================================================================
  69.  
  70.