Unix Technical Forum

aCC Compiler error : Cannot use extern object of unknown size

This is a discussion on aCC Compiler error : Cannot use extern object of unknown size within the HP-UX Operating System forums, part of the Unix Operating Systems category; --> Hi, I am trying to compile following piece of code (bb.cpp) using aCC (HP ANSI C++ B3910B A.03.37) compiler ...


Go Back   Unix Technical Forum > Unix Operating Systems > HP-UX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-16-2008, 08:59 PM
Manoj Pattanaik
 
Posts: n/a
Default aCC Compiler error : Cannot use extern object of unknown size

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();
^^^^^^

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-16-2008, 08:59 PM
Paul Pluzhnikov
 
Posts: n/a
Default Re: aCC Compiler error : Cannot use extern object of unknown size

"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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:18 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com