By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,485 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,485 IT Pros & Developers. It's quick & easy.

visual 2008: can't find header

P: n/a
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
Oct 14 '08 #1
Share this Question
Share on Google+
12 Replies


P: n/a
On Oct 14, 8:59*pm, Adam Chapman
<adam.chap...@student.manchester.ac.ukwrote:
Hi,

Im using Visual C++ 2008, I made a header file (well, copied the
header "cat.h" fromhttp://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
Aha! Should have used "cat.h" rather than <cat.h>. Is this a standard
syntax for user-created headers?
Oct 14 '08 #2

P: n/a
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 sm**@spam.causeway.com
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
Oct 14 '08 #3

P: n/a
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 sm**@spam.causeway.com
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
Oct 14 '08 #4

P: n/a
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 .... .

Oct 14 '08 #5

P: n/a

"Adam Chapman" <ad**********@student.manchester.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.
http://www.personal.leeds.ac.uk/~bgy1mm

Oct 14 '08 #6

P: n/a
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.
Oct 14 '08 #7

P: n/a
On October 14, 2008 16:25, in comp.lang.c, Adam Chapman
(ad**********@student.manchester.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 "translation 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. ------
Oct 14 '08 #8

P: n/a
On October 14, 2008 17:08, in comp.lang.c, Lew Pitcher
(lp******@teksavvy.com) wrote:
On October 14, 2008 16:25, in comp.lang.c, Adam Chapman
(ad**********@student.manchester.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. ------
Oct 14 '08 #9

P: n/a
On Tue, 14 Oct 2008 17:08:33 -0400, Lew Pitcher wrote:
On October 14, 2008 16:25, in comp.lang.c, Adam Chapman
(ad**********@student.manchester.ac.uk) wrote:
>http://en.wikipedia.org/wiki/Opaque_pointer
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.
Oct 14 '08 #10

P: n/a
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.
Oct 14 '08 #11

P: n/a
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
Oct 15 '08 #12

P: n/a
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.
Oct 16 '08 #13

This discussion thread is closed

Replies have been disabled for this discussion.