Re: template under gcc version 3.3.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



corey taylor wrote:

Morten,

 First one note, I don't see you including anything for the std::deque type.

 You should at least add: #include <deque>

corey



g++ -ansi -pedantic -Wall -o stest5_test_00.out stest5_test_00.cpp -L
/opt/sfw/gcc-3/lib/ -R /opt/sfw/gcc-3/lib/ -lstdc++
stest5_test_00.cpp:11: error: syntax error before `;' token

#include <iostream>
#include <string>
#include <cstdlib>

// #include "stack5.hpp"

template <typename T>
class Stack {
private:
std::deque<T> elems; // elements





OK   I did,

The preceeding code  files   are all good,

I also tried  www.comeaucomputing.com




#include <iostream> #include <string> #include <cstdlib>

#include <deque>
#include <vector>
#include <stdexcept>



// #include "stack5.hpp"

// these files are unchanged
#include "stack5decl.hpp"
#include "stack5assign.hpp"




int main()
{
   try {
       Stack<int>   intStack;       // stack of ints
       Stack<float> floatStack;     // stack of floats

       // manipulate int stack
       intStack.push(42);
       intStack.push(7);

       // manipulate float stack
       floatStack.push(7.7);

       // assign stacks of different type
       floatStack = intStack;

       // print float stack
       std::cout << floatStack.top() << std::endl;
       floatStack.pop();
       std::cout << floatStack.top() << std::endl;
       floatStack.pop();
       std::cout << floatStack.top() << std::endl;
       floatStack.pop();
   }
   catch (std::exception const& ex) {
       std::cerr << "Exception: " << ex.what() << std::endl;
       return EXIT_FAILURE;  // exit program with ERROR status
   }
}



/*

g++ -o stest5.out stest5.cpp -L /opt/sfw/gcc-3/lib -R /opt/sfw/gcc-3/lib -lstdc++

Undefined                       first referenced
symbol                             in file
Stack<int>::push(int const&)        /var/tmp//ccy3WHcF.o
Stack<float>::push(float const&)    /var/tmp//ccy3WHcF.o
Stack<int>::pop()                   /var/tmp//ccy3WHcF.o
Stack<float>::pop()                 /var/tmp//ccy3WHcF.o
Stack<float>::top() const           /var/tmp//ccy3WHcF.o
Stack<int>::top() const             /var/tmp//ccy3WHcF.o
ld: fatal: Symbol referencing errors. No output written to stest5.out
collect2: ld returned 1 exit status


g++ -v -o stest5.out stest5.cpp -L /opt/sfw/gcc-3/lib -R /opt/sfw/gcc-3/lib -lstdc++
Reading specs from /opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/specs
Configured with: ../gcc-3.3.2/configure --prefix=/opt/sfw/gcc-3 --with-ld=/usr/ccs/bin/ld --with-as=/usr/ccs/bin/as --without-gnu-ld --without-gnu-as --enable-shared
Thread model: posix
gcc version 3.3.2
/opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/cc1plus -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 stest5.cpp -D__GNUG__=3 -quiet -dumpbase stest5.cpp -auxbase stest5 -version -o /var/tmp//ccDX6SkL.s
GNU C++ version 3.3.2 (i386-pc-solaris2.9)
compiled by GNU C version 3.3.2.
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32718
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/opt/sfw/gcc-3/i386-pc-solaris2.9/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/sfw/gcc-3/include/c++/3.3.2
/opt/sfw/gcc-3/include/c++/3.3.2/i386-pc-solaris2.9
/opt/sfw/gcc-3/include/c++/3.3.2/backward
/opt/sfw/gcc-3/include
/opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/include
/usr/include
End of search list.
/usr/ccs/bin/as -V -Qy -s -o /var/tmp//cc7CpDtM.o /var/tmp//ccDX6SkL.s
as: Sun Compiler Common 9.0 Patch 115114-02 2004/02/09
/opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/collect2 -V -R /opt/sfw/gcc-3/lib -Y P,/usr/ccs/lib:/usr/lib -Qy -o stest5.out /opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/crt1.o /opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/crti.o /usr/ccs/lib/values-Xa.o /opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/crtbegin.o -L /opt/sfw/gcc-3/lib -L/opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2 -L/usr/ccs/bin -L/usr/ccs/lib -L/opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/../../.. /var/tmp//cc7CpDtM.o -lstdc++ -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/crtend.o /opt/sfw/gcc-3/lib/gcc-lib/i386-pc-solaris2.9/3.3.2/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.9-1.385
Undefined first referenced
symbol in file
Stack<int>::push(int const&) /var/tmp//cc7CpDtM.o
Stack<float>::push(float const&) /var/tmp//cc7CpDtM.o
Stack<int>::pop() /var/tmp//cc7CpDtM.o
Stack<float>::pop() /var/tmp//cc7CpDtM.o
Stack<float>::top() const /var/tmp//cc7CpDtM.o
Stack<int>::top() const /var/tmp//cc7CpDtM.o
ld: fatal: Symbol referencing errors. No output written to stest5.out
collect2: ld returned 1 exit status



*/



best regards

Morten



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux