If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

.h file extensions and compiler tool

I am new at this. I am trying to set up a header file in the C++ compiler
-- very unsuccessfully so
far. My code builds just fine, no errors or warnings. However, when I try
to compile it, I get the
message that there is "no compile tool associated with the .h file extension.
I have trashed
my code and project file and started new several times. I have uninstalled
the Visual C++ compiler
and then did a complete reinstall. Nothing helps. Here is the code that
I am trying to compile:

PLEASE DON'T suggest that I ad the #ifndef, #define, #endif to the code it
does not work, I have
already tried it. And again, it builds error and warning free, but it will
not compile and I get the same
message.

I had someone else write this code on his computer and he did not have any
trouble compiling it. I
took what he wrote and tried to compile it on my computer and it would not
compile!

What am I doing wrong???? After less than a week into this stuff and I am
ready to give up!

Here are the steps that I have gone through to set up the header file:

Using the Win32 Console Application, I set up a new (empty) project. Then
I select "New"
and "C++ header file", name it and tell it to add it to the project. Then
I enter the code which
builds without error. It will not compile!

IS THERE ANYONE OUT THERE WHO CAN HELP ME??? I REALLY WOULD APPRECIATE IT!!!

"Louise" <louise1007@mindspring.com> wrote:
>
>I am new at this. I am trying to set up a header file in the C++ compiler
>-- very unsuccessfully so
>far. My code builds just fine, no errors or warnings. However, when I
try
>to compile it, I get the
>message that there is "no compile tool associated with the .h file extension.
> I have trashed
>my code and project file and started new several times. I have uninstalled
>the Visual C++ compiler
>and then did a complete reinstall. Nothing helps. Here is the code that
>I am trying to compile:
>
>#include <iostream.h>
> class Cat
>public:
> Cat (int initialAge);
> ~Cat();
> int GetAge() const { return itsAge;}
> void SetAge (int age) { itsAge = age;}
> void Meow() const { cout << "Meow.\n";}
>private:
> int itsAge;
>};
>
>PLEASE DON'T suggest that I ad the #ifndef, #define, #endif to the code
it
>does not work, I have
>already tried it. And again, it builds error and warning free, but it will
>not compile and I get the same
>message.
>
>I had someone else write this code on his computer and he did not have any
>trouble compiling it. I
>took what he wrote and tried to compile it on my computer and it would not
>compile!
>
>What am I doing wrong???? After less than a week into this stuff and I
am
>ready to give up!
>
>Here are the steps that I have gone through to set up the header file:
>
>Using the Win32 Console Application, I set up a new (empty) project. Then
>I select "New"
>and "C++ header file", name it and tell it to add it to the project. Then
>I enter the code which
>builds without error. It will not compile!
>
>IS THERE ANYONE OUT THERE WHO CAN HELP ME??? I REALLY WOULD APPRECIATE
IT!!!
>

Re: .h file extensions and compiler tool

Combine the header and the code into one .cpp file. Include as .cpp. See
if you can build into a .exe from this.

and does the build give you an exe file? Yet compile does not work?

Finally, turn off extension hiding in windows (if its on). ensure the .h
has a .h extension.

Answer this and we can narrow it down.

"Louise" <louise1007@mindspring.com> wrote:
>
>I am new at this. I am trying to set up a header file in the C++ compiler
>-- very unsuccessfully so
>far. My code builds just fine, no errors or warnings. However, when I
try
>to compile it, I get the
>message that there is "no compile tool associated with the .h file extension.
> I have trashed
>my code and project file and started new several times. I have uninstalled
>the Visual C++ compiler
>and then did a complete reinstall. Nothing helps. Here is the code that
>I am trying to compile:
>
>#include <iostream.h>
> class Cat
>public:
> Cat (int initialAge);
> ~Cat();
> int GetAge() const { return itsAge;}
> void SetAge (int age) { itsAge = age;}
> void Meow() const { cout << "Meow.\n";}
>private:
> int itsAge;
>};
>
>PLEASE DON'T suggest that I ad the #ifndef, #define, #endif to the code
it
>does not work, I have
>already tried it. And again, it builds error and warning free, but it will
>not compile and I get the same
>message.
>
>I had someone else write this code on his computer and he did not have any
>trouble compiling it. I
>took what he wrote and tried to compile it on my computer and it would not
>compile!
>
>What am I doing wrong???? After less than a week into this stuff and I
am
>ready to give up!
>
>Here are the steps that I have gone through to set up the header file:
>
>Using the Win32 Console Application, I set up a new (empty) project. Then
>I select "New"
>and "C++ header file", name it and tell it to add it to the project. Then
>I enter the code which
>builds without error. It will not compile!
>
>IS THERE ANYONE OUT THERE WHO CAN HELP ME??? I REALLY WOULD APPRECIATE
IT!!!
>

Re: .h file extensions and compiler tool

in addition to the missing opening brace in class Cat, use <iostream>
(with the appropriate using-declarations) not <iostream.h>, define the
main() function, and create your project as a Console App because that's
what it is.

Re: .h file extensions and compiler tool

if you are using <iostream> and not <iostream.h>
then you have to use the following declaration :

using namespace std;

rgds
bopu

"Dr_Muerte" <Unknow@Unknow.pi> wrote:
>
>Prueba esto:
>#include <iostream> // <- sin .h
> class Cat
>{ // <- inicio de clase
>public:
> Cat (int initialAge);
> ~Cat();
> int GetAge() const { return itsAge;}
> void SetAge (int age) { itsAge = age;}
> void Meow() const { cout << "Meow.\n";}
>private:
> int itsAge;
>};
>
>
>"Louise" <louise1007@mindspring.com> wrote:
>>
>>I am new at this. I am trying to set up a header file in the C++ compiler
>>-- very unsuccessfully so
>>far. My code builds just fine, no errors or warnings. However, when I
>try
>>to compile it, I get the
>>message that there is "no compile tool associated with the .h file extension.
>> I have trashed
>>my code and project file and started new several times. I have uninstalled
>>the Visual C++ compiler
>>and then did a complete reinstall. Nothing helps. Here is the code that
>>I am trying to compile:
>>
>>#include <iostream.h>
>> class Cat
>>public:
>> Cat (int initialAge);
>> ~Cat();
>> int GetAge() const { return itsAge;}
>> void SetAge (int age) { itsAge = age;}
>> void Meow() const { cout << "Meow.\n";}
>>private:
>> int itsAge;
>>};
>>
>>PLEASE DON'T suggest that I ad the #ifndef, #define, #endif to the code
>it
>>does not work, I have
>>already tried it. And again, it builds error and warning free, but it
will
>>not compile and I get the same
>>message.
>>
>>I had someone else write this code on his computer and he did not have
any
>>trouble compiling it. I
>>took what he wrote and tried to compile it on my computer and it would
not
>>compile!
>>
>>What am I doing wrong???? After less than a week into this stuff and I
>am
>>ready to give up!
>>
>>Here are the steps that I have gone through to set up the header file:
>>
>>Using the Win32 Console Application, I set up a new (empty) project. Then
>>I select "New"
>>and "C++ header file", name it and tell it to add it to the project. Then
>>I enter the code which
>>builds without error. It will not compile!
>>
>>IS THERE ANYONE OUT THERE WHO CAN HELP ME??? I REALLY WOULD APPRECIATE
>IT!!!
>>
>

Re: .h file extensions and compiler tool

"Louise" <louise1007@mindspring.com> wrote:
>
>I am new at this. I am trying to set up a header file in the C++ compiler
>-- very unsuccessfully so
>far. My code builds just fine, no errors or warnings. However, when I
try
>to compile it, I get the
>message that there is "no compile tool associated with the .h file extension.
> I have trashed
>my code and project file and started new several times. I have uninstalled
>the Visual C++ compiler
>and then did a complete reinstall. Nothing helps. Here is the code that
>I am trying to compile:
>
>#include <iostream.h>
> class Cat
>public:
> Cat (int initialAge);
> ~Cat();
> int GetAge() const { return itsAge;}
> void SetAge (int age) { itsAge = age;}
> void Meow() const { cout << "Meow.\n";}
>private:
> int itsAge;
>};
>
>PLEASE DON'T suggest that I ad the #ifndef, #define, #endif to the code
it
>does not work, I have
>already tried it. And again, it builds error and warning free, but it will
>not compile and I get the same
>message.
>
>I had someone else write this code on his computer and he did not have any
>trouble compiling it. I
>took what he wrote and tried to compile it on my computer and it would not
>compile!
>
>What am I doing wrong???? After less than a week into this stuff and I
am
>ready to give up!
>
>Here are the steps that I have gone through to set up the header file:
>
>Using the Win32 Console Application, I set up a new (empty) project. Then
>I select "New"
>and "C++ header file", name it and tell it to add it to the project. Then
>I enter the code which
>builds without error. It will not compile!
>
>IS THERE ANYONE OUT THERE WHO CAN HELP ME??? I REALLY WOULD APPRECIATE
IT!!!
>

Hi Louise!

The thing is, you can never compile a .h file, at least not with any version
of VC++. What happens when you choose to build your project is that the compiler
compiles your source (.cpp) files, thus including AND compiling the header
files that are included in your source files, producing object (.obj) files
that are linked together to produce an executable file. This of course assumes
that you have at least one source file with a complete main() function. Otherwise,
I can't think of any other error than the previously mentioned 'missing opening
curly brace in class declaration' suggestion to what's wrong. But that doesn't
quite seem to be the source of the error either.