#pragma problem?

S

Songling

I had some very interesting include problems. Please see descriptions below.

In "MyObj.cc" file, I used the following lines to do the include,

#pragma implementation <MyObj.h>

#include <MyObj.h>

In "MyObj.h" file, I do the followings,

#pragma interface

#include <MyHdr.h>

In "MyHdr.h" I define type A. But when I try to use type A in "MyObj.cc",
the complier
complains that type A is undefined. The compiler I'm using should be
diab-5.1.

Can anybody be kind enough to help?

Thanks!

Songling
 
V

Victor Bazarov

Songling said:
I had some very interesting include problems. Please see descriptions below.

In "MyObj.cc" file, I used the following lines to do the include,

#pragma implementation <MyObj.h>

#include <MyObj.h>

In "MyObj.h" file, I do the followings,

#pragma interface

#include <MyHdr.h>

In "MyHdr.h" I define type A. But when I try to use type A in "MyObj.cc",
the complier
complains that type A is undefined. The compiler I'm using should be
diab-5.1.

Can anybody be kind enough to help?

Somebody in a newsgroup dedicated to your compiler must be able to.
#pragma directives are compiler-specific.

If you just do
------------------------------------------- in MyObj.h
#include <MyHdr.h>
------------------------------------------- in MyObj.cc
#include <MyObj.h>
A a;
------------------------------------------- in MyHdr.h
class A {};
-------------------------------------------
, does it work? If it does, you don't have a C++ problem. And even
if it doesn't, are you sure you're including the right files from the
right locations? Specifying the locations where the headers are found
is also compiler-specific, unfortunately.

Drop the pragmas and try again. If it still doesn't work, reduce your
code to the bare minimum that doesn't work and post it here.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top