visual 2008: can't find header

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam Chapman

    visual 2008: can't find header

    Hi,

    Im using Visual C++ 2008, I made a header file (well, copied the
    header "cat.h" from http://en.wikipedia.org/wiki/Opaque_pointer)

    The only mention of cat.h I have in my script containing main() is the
    line:
    #include <cat.h>

    I've saved the header file within the same project as the script
    containing main. When compiling, i get the error message:

    fatal error C1083: Cannot open include file: 'cat.h': No such file or
    directory

    Im incredibly new to C, and my guess is that I need to tell the
    compiler to look in my project directory for headers.

    Does anyone know how to do this or can advise me otherwise?

    Thanks,
    Adam
  • Adam Chapman

    #2
    Re: visual 2008: can't find header

    On Oct 14, 8:59 pm, Adam Chapman
    <adam.chap...@s tudent.manchest er.ac.ukwrote:
    Hi,
    >
    Im using Visual C++ 2008, I made a header file (well, copied the
    header "cat.h" fromhttp://en.wikipedia.or g/wiki/Opaque_pointer)
    >
    The only mention of cat.h I have in my script containing main() is the
    line:
    #include <cat.h>
    >
    I've saved the header file within the same project as the script
    containing main. When compiling, i get the error message:
    >
    fatal error C1083: Cannot open include file: 'cat.h': No such file or
    directory
    >
    Im incredibly new to C, and my guess is that I need to tell the
    compiler to look in my project directory for headers.
    >
    Does anyone know how to do this or can advise me otherwise?
    >
    Thanks,
    Adam
    Aha! Should have used "cat.h" rather than <cat.h>. Is this a standard
    syntax for user-created headers?

    Comment

    • Flash Gordon

      #3
      Re: visual 2008: can't find header

      Adam Chapman wrote, On 14/10/08 20:59:
      Hi,
      >
      Im using Visual C++ 2008, I made a header file (well, copied the
      header "cat.h" from http://en.wikipedia.org/wiki/Opaque_pointer)
      >
      The only mention of cat.h I have in my script containing main() is the
      line:
      #include <cat.h>
      You should ony use angle brackets for include files provided by your
      system, you should use double-quotes for headers you provide. I.e. try

      #include "cat.h"
      I've saved the header file within the same project as the script
      containing main. When compiling, i get the error message:
      >
      fatal error C1083: Cannot open include file: 'cat.h': No such file or
      directory
      >
      Im incredibly new to C, and my guess is that I need to tell the
      compiler to look in my project directory for headers.
      >
      Does anyone know how to do this or can advise me otherwise?
      For help on how to use Visual Studio you should use one of the Windows
      programming groups. However my guess is that with the change above you
      will get rid of the error.
      --
      Flash Gordon
      If spamming me sent it to smap@spam.cause way.com
      If emailing me use my reply-to address
      See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/

      Comment

      • Flash Gordon

        #4
        Re: visual 2008: can't find header

        Adam Chapman wrote, On 14/10/08 21:02:

        <snip>
        Aha! Should have used "cat.h" rather than <cat.h>. Is this a standard
        syntax for user-created headers?
        Yes. Quotes for user headers angle brackets for system provided headers.
        --
        Flash Gordon
        If spamming me sent it to smap@spam.cause way.com
        If emailing me use my reply-to address
        See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/

        Comment

        • Adam Chapman

          #5
          Re: visual 2008: can't find header

          Thanks guys.

          Looking at the C example at http://en.wikipedia.org/wiki/Opaque_pointer
          , Could you show me how to use the create_Cat function from my main
          script? I'ts difficult to tell what inputs I need, most probably
          because Im dumb. I think it would be something like this:

          #include "cat.h"

          main(void){
          int smile;
          smile = 1;
          ..... create_Cat(int smile);
          }

          But am not sure what to put in the place of the .... .



          Comment

          • Malcolm McLean

            #6
            Re: visual 2008: can't find header


            "Adam Chapman" <adam.chapman@s tudent.manchest er.ac.ukwrote in message
            Thanks guys.
            >
            Looking at the C example at http://en.wikipedia.org/wiki/Opaque_pointer
            , Could you show me how to use the create_Cat function from my main
            script? I'ts difficult to tell what inputs I need, most probably
            because Im dumb. I think it would be something like this:
            >
            #include "cat.h"
            >
            main(void){
            int smile;
            smile = 1;
            .... create_Cat(int smile);
            }
            >
            But am not sure what to put in the place of the .... .
            >
            what does create_Cat return? Can you show us the contents of cat.h ?
            --
            Free games and programming goodies.


            Comment

            • Adam Chapman

              #7
              Re: visual 2008: can't find header

              what does create_Cat return? Can you show us the contents of cat.h ?
              My understanding is that create_Cat creates a new variable with a data
              type defied in cat.h . I want to know how to call it so I can make my
              own. I plan to make a structure type which holds 2D matrix values and
              dimensions.

              Comment

              • Lew Pitcher

                #8
                Re: visual 2008: can't find header

                On October 14, 2008 16:25, in comp.lang.c, Adam Chapman
                (adam.chapman@s tudent.manchest er.ac.uk) wrote:
                Thanks guys.
                >
                Looking at the C example at http://en.wikipedia.org/wiki/Opaque_pointer
                , Could you show me how to use the create_Cat function from my main
                script? I'ts difficult to tell what inputs I need, most probably
                because Im dumb. I think it would be something like this:
                >
                #include "cat.h"
                >
                main(void){
                int smile;
                smile = 1;
                .... create_Cat(int smile);
                }
                >
                But am not sure what to put in the place of the .... .
                OK. You /really/ need help learning C, don't you. Are you certain that your
                name isn't "Bill Cunningham"?

                1) You will need to compile the second set of logic shown on that webpage,
                either as part of the source code file (officially, the "translatio n unit")
                that your main() function is in, or as a separate source code file. If you
                choose to make it a separate source code file, you will have to instruct
                your linker to use the compiled functions when it links your main()
                function.

                2) The "cat.h" example file given on the webpage is incomplete. It provides
                typedef struct cat_t *cat_handle;
                which makes the typename cat_handle to be an alias to the type
                "pointer to struct cat_t"
                but it /does not/ define the
                struct cat_t
                at all. However, you can find the structure definition for cat_t in the
                second example code. My recommendation would be to remove it from the
                second example, and move it to the cat.h header.

                3) You actually had a good start in the lines above. Assuming that you move
                the cat_t structure definition to cat.h, you will need something like...

                #include "cat.h"

                int main(void)
                {
                cat_handle MyCat;

                MyCat = createCat(1);

                /* what ever other logic you want to use goes here */

                return 0;
                }


                HTH
                --
                Lew Pitcher

                Master Codewright & JOAT-in-training | Registered Linux User #112576
                http://pitcher.digitalfreehold.ca/ | GPG public key available by request
                ---------- Slackware - Because I know what I'm doing. ------


                Comment

                • Lew Pitcher

                  #9
                  Re: visual 2008: can't find header

                  On October 14, 2008 17:08, in comp.lang.c, Lew Pitcher
                  (lpitcher@teksa vvy.com) wrote:
                  On October 14, 2008 16:25, in comp.lang.c, Adam Chapman
                  (adam.chapman@s tudent.manchest er.ac.uk) wrote:
                  >
                  >Thanks guys.
                  >>
                  >Looking at the C example at http://en.wikipedia.org/wiki/Opaque_pointer
                  [snip]
                  2) The "cat.h" example file given on the webpage is incomplete. It
                  provides
                  typedef struct cat_t *cat_handle;
                  which makes the typename cat_handle to be an alias to the type
                  "pointer to struct cat_t"
                  but it /does not/ define the
                  struct cat_t
                  at all. However, you can find the structure definition for cat_t in the
                  second example code. My recommendation would be to remove it from the
                  second example, and move it to the cat.h header.
                  Oops. I screwed that one up, didn't I?

                  The whole point of data hiding is that you don't have to do what I told you
                  to do. If I were on SNL in the 80's, I'd say "Never mind" (others will get
                  the reference), but I'm not, so I'll just apologize instead.

                  With the code supplied, all you have to do is....

                  #include "cat.h"

                  int main(void)
                  {
                  cat_handle MyCat;

                  MyCat = create_Cat(1);
                  /* et cetera */

                  return 0;
                  }



                  [snip]

                  --
                  Lew Pitcher

                  Master Codewright & JOAT-in-training | Registered Linux User #112576
                  http://pitcher.digitalfreehold.ca/ | GPG public key available by request
                  ---------- Slackware - Because I know what I'm doing. ------


                  Comment

                  • Harald van =?UTF-8?b?RMSzaw==?=

                    #10
                    Re: visual 2008: can't find header

                    On Tue, 14 Oct 2008 17:08:33 -0400, Lew Pitcher wrote:
                    On October 14, 2008 16:25, in comp.lang.c, Adam Chapman
                    (adam.chapman@s tudent.manchest er.ac.uk) wrote:2) The "cat.h" example file given on the webpage is incomplete. It
                    provides
                    typedef struct cat_t *cat_handle;
                    which makes the typename cat_handle to be an alias to the type
                    "pointer to struct cat_t"
                    but it /does not/ define the
                    struct cat_t
                    at all.
                    The idea is to not expose the definition of struct cat_t, because the
                    calling code doesn't need it.
                    However, you can find the structure definition for cat_t in the
                    second example code. My recommendation would be to remove it from the
                    second example, and move it to the cat.h header.
                    My recommendation would be to leave it in its current place.

                    Comment

                    • CBFalconer

                      #11
                      Re: visual 2008: can't find header

                      Adam Chapman wrote:
                      >
                      Im using Visual C++ 2008, I made a header file (well, copied the
                      header "cat.h" from http://en.wikipedia.org/wiki/Opaque_pointer)
                      >
                      The only mention of cat.h I have in my script containing main()
                      is the line:
                      #include <cat.h>
                      That line searches only the area that holds system headers. cat.h
                      is not a system header, it is something of yours, so use:

                      #include "cat.h"

                      Note the quote markers.

                      --
                      [mail]: Chuck F (cbfalconer at maineline dot net)
                      [page]: <http://cbfalconer.home .att.net>
                      Try the download section.

                      Comment

                      • Richard Nixon

                        #12
                        Re: visual 2008: can't find header

                        On Tue, 14 Oct 2008 18:36:13 -0400, CBFalconer wrote:
                        Adam Chapman wrote:
                        >>
                        >Im using Visual C++ 2008, I made a header file (well, copied the
                        >header "cat.h" from http://en.wikipedia.org/wiki/Opaque_pointer)
                        >>
                        >The only mention of cat.h I have in my script containing main()
                        >is the line:
                        >#include <cat.h>
                        >
                        That line searches only the area that holds system headers. cat.h
                        is not a system header, it is something of yours, so use:
                        >
                        #include "cat.h"
                        >
                        Note the quote markers.
                        Gosh, CB, your politeness reminds me of your better nature.

                        For the OP, will you go out and find a good newsgroup where this is
                        topical? (A good one)

                        Please repost when you succeed.
                        --
                        Richard Milhous Nixon

                        The very ink with which all history is written is merely fluid prejudice.
                        ~~ Mark Twain

                        Comment

                        • CBFalconer

                          #13
                          Re: visual 2008: can't find header

                          Richard Nixon wrote:
                          CBFalconer wrote:
                          >Adam Chapman wrote:
                          >>
                          >>Im using Visual C++ 2008, I made a header file (well, copied the
                          >>header "cat.h" from http://en.wikipedia.org/wiki/Opaque_pointer)
                          >>>
                          >>The only mention of cat.h I have in my script containing main()
                          >>is the line:
                          >>#include <cat.h>
                          >>
                          >That line searches only the area that holds system headers. cat.h
                          >is not a system header, it is something of yours, so use:
                          >>
                          > #include "cat.h"
                          >>
                          >Note the quote markers.
                          >
                          Gosh, CB, your politeness reminds me of your better nature.
                          >
                          For the OP, will you go out and find a good newsgroup where this is
                          topical? (A good one)
                          Well done. You have trolled yourself into the PLONK bin. Bye.

                          --
                          [mail]: Chuck F (cbfalconer at maineline dot net)
                          [page]: <http://cbfalconer.home .att.net>
                          Try the download section.

                          Comment

                          Working...