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 error:485
//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();
^^^^^^
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? 3 2921 ma************* @gmail.com wrote: 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 error:485
//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(); ^^^^^^ 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?
since you referred to objabc.func();, the definition of class abc must
be known prior to this reference.
Fei Liu wrote: ma************* @gmail.com wrote: 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 error:485
//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(); ^^^^^^ 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?
since you referred to objabc.func();, the definition of class abc must be known prior to this reference.
Well, that's not precisely true, as we're talking templates here.
They're compiled
in one context and perhaps instantiated in another. However, the
solution is
obvious: Either include the header that defines class abc, or (better)
remove the
object from the header, wrap the call in a non-template function and
put that
function declaration in the header instead. This works because
objabc.func()
doesn't depend on the template type.
For better encapsulation, the wrapper function can be made a protected
method
of a private non-template base class.
HTH,
Michiel Salters Mi************* @tomtom.com wrote: Fei Liu wrote: ma************* @gmail.com wrote: 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 error:485
//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(); ^^^^^^ 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?
since you referred to objabc.func();, the definition of class abc must be known prior to this reference.
Well, that's not precisely true, as we're talking templates here. They're compiled in one context and perhaps instantiated in another. However, the
objabc is a non-dependent name and will be looked up during declaration
by a standard confoming compiler. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alf P. Steinbach |
last post by:
// As usual the error message directs one to the report the bug.
//
// And as usual there is absolutely no way to do so without paying for
// the privilege...
//
// Or using three or four hours to find the _current_ reporting page...
#include <vector>
#include <iostream>
|
by: Christopher M. Lusardi |
last post by:
Hello,
Can I run the subject line program using CC instead of cc? I attempted
to use the "-c" option and it told me things were undefined. Isn't this
CC option the same as the cc -c option?
Thank you,
Christopher Lusardi
|
by: yanwan |
last post by:
Hello
I am now compling a project, but in one source file of this project, I met
this problem. It seems very strange.
Below is this source file:
----------------------------------------
#include "icarus_types.h"
#ifdef WIN32
#include <GL/glu.h>
|
by: DiskMan |
last post by:
System:
Redhat 7.2
Kernel-2.6.11.8
GCC-3.4.3
CCC-6.5.9
Binutils-2.15
Make-3.80
GTK/GLIB-2.6.7
For some reason my Linux box is suddenly having issues trying to read ;
|
by: B Vidyadhar Joshi |
last post by:
I was writing an Bluetooth Application which makes calls to Windows APIs. I
feel I'm doing something wrong with the structure. Could somebody help me?
The code that I'm using is pasted below:
using System;
using System.Runtime.InteropServices;
namespace System.Net.Bluetooth
{
public class BLUETOOTH_FIND_RADIO_PARAMS
| |
by: HKSHK |
last post by:
This list compares the error codes used in VB.NET 2003 with those used
in VB6.
Error Codes:
============
3: This Error number is obsolete and no longer used. (Formerly:
Return without GoSub)
5: Procedure call or argument is not valid.
6: Overflow.
7: Out of memory.
|
by: dancer |
last post by:
I am using Framework 1.1.4322.
Who can tell me why I'm getting this error? My code follows
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: BC30456: 'Text' is not a member of
'System.Web.UI.WebControls.CheckBoxList'.
|
by: Rene |
last post by:
Hello to all!
For a long time I have been "fighting" a problem compiling an OpenGL
program which uses GLUT. First I have put a question in a Watcom group
(I want to use this compiler) to which I got no reply, in an OpenGL
group somebody recommended me to use Visual C++ which I did. That worked
OK but I do would like to use Watcom.
In the meantime I found solutions to several of the errors I got but one
is left which I cannot find a...
|
by: Dave |
last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU
compilers. I then decided to try to use Sun's compiler. The Sun Studio
12 compiler reports the following code, which is in the source
(gcc-4.3.1/gcc/c-common.c) of gcc 4.3.1, is a syntax error.
I'm inclined to agree, as it is like no C I have ever met.
what is "C_COMMON_FIXED_TYPES (, fract);" supposed to mean? Could it be
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |