#pragma problem?

Discussion in 'C++' started by Songling, Oct 13, 2004.

  1. Songling

    Songling Guest

    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
     
    Songling, Oct 13, 2004
    #1
    1. Advertising

  2. Songling wrote:
    > 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
     
    Victor Bazarov, Oct 13, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    9
    Views:
    13,970
    Rob Dekker
    Jul 21, 2005
  2. ryang
    Replies:
    1
    Views:
    948
    Wes Groleau
    Apr 11, 2005
  3. Titus A Ducksass
    Replies:
    1
    Views:
    6,031
    Sid Ismail
    Aug 1, 2003
  4. Paul J. Le Genial

    [Q] pragma no-cache : what about the images ?

    Paul J. Le Genial, Mar 14, 2005, in forum: HTML
    Replies:
    5
    Views:
    7,478
  5. Denis Lagno

    Re: pragma

    Denis Lagno, Oct 4, 2003, in forum: C++
    Replies:
    0
    Views:
    418
    Denis Lagno
    Oct 4, 2003
Loading...

Share This Page