vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I am trying to compile following piece of code (bb.cpp) using aCC (HP ANSI C++ B3910B A.03.37) compiler on HP-UX 11.23. It gives Compiler error:485. Same code is compiling fine with VC++ (Windows), CC (Solaris 9), gcc (LInux). Can anyone please help me to compile it with aCC compiler on HPUX without making any change in the code? //bb.cpp -- Starts #include <iostream> using namespace std; class abc; extern abc objabc; template <class a> class def { public: void disp() { objabc.func(); } }; class abc { public: void func() { cout<<"from func"<<endl; } }; abc objabc; //bb.cpp -- Ends aCC -AA -c bb.cpp -o bb.o Error 485: "bb.cpp", line 17 # Cannot use extern object of unknown size; 'abc' must be defined first. "abc objabc" was declared at ["bb.cpp", line 8]. objabc.func(); ^^^^^^ |
| ||||
| "Manoj Pattanaik" <manoj.pattanaik@gmail.com> writes: > I am trying to compile following piece of code (bb.cpp) using aCC (HP > ANSI C++ B3910B A.03.37) compiler on HP-UX 11.23. It gives Compiler > error:485. As it should: you can't call methods of a class that has not yet been defined. > Same code is compiling fine with VC++ (Windows), CC (Solaris 9), gcc > (LInux). This is because these compilers don't parse templates when they see them, but do it later, when the template is actually instantiated. Your code does *not* compile with g++-4.1: $ /usr/local/gcc-4.1-20051022/bin/g++ junk.cc -c junk.cc: In member function 'void def<a>::disp()': junk.cc:14: error: invalid use of undefined type 'struct abc' junk.cc:4: error: forward declaration of 'struct abc' > Can anyone please help me to compile it with aCC compiler on > HPUX without making any change in the code? Why don't you just fix broken code? Cheers, -- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email. |