#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. Advertisements

  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. Advertisements

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:
    16,725
    Rob Dekker
    Jul 21, 2005
  2. ryang
    Replies:
    1
    Views:
    1,142
    Wes Groleau
    Apr 11, 2005
  3. Titus A Ducksass
    Replies:
    1
    Views:
    6,175
    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,746
  5. WAK

    #pragma

    WAK, Nov 28, 2003, in forum: C++
    Replies:
    1
    Views:
    558
    Karl Heinz Buchegger
    Nov 28, 2003
  6. JustSomeGuy

    how does pragma pack work?

    JustSomeGuy, Dec 9, 2003, in forum: C++
    Replies:
    1
    Views:
    3,873
    Pete Becker
    Dec 9, 2003
  7. Jacob Jensen

    pragma once

    Jacob Jensen, Apr 3, 2004, in forum: C++
    Replies:
    14
    Views:
    8,926
    Julie
    Apr 5, 2004
  8. Shri

    Pragma Document

    Shri, May 31, 2004, in forum: C++
    Replies:
    3
    Views:
    400
    Mike Smith
    Jun 2, 2004
Loading...