C++: compiling header files

A

A

Hi,

Can you actually compile header files? I'm writing a header file named
"test.h" using Visual C++ 6.0 and I get the following error message when I
try to compile it:

"no compile tool associated with this file extension".

Anyway, I thought the compiler will just do a syntax check, but it seems it
doesn't like it. Any comments appreciated.

side note: what does precompiled header mean?


Regards,
A
 
T

Thomas Matthews

A said:
Hi,

Can you actually compile header files? I'm writing a header file named
"test.h" using Visual C++ 6.0 and I get the following error message when I
try to compile it:

"no compile tool associated with this file extension".

Anyway, I thought the compiler will just do a syntax check, but it seems it
doesn't like it. Any comments appreciated.

side note: what does precompiled header mean?


Regards,
A

Some compilers allow precompiled headers.
When a compiler "precompiles" a header, it parses the text and
stores the relevant information (definitions & declarations)
in file for later usage. Next time the compiler encounters
the header file, it doesn't need to parse the text again;
it just uses the definitions that it stored away.

The precompilation step is supposed to speed up the
compilation process, especially for large header files
{like those encountered for MS Windows). Although there
is no standard for precompilation, some compilers give
out warnings, such as "Cannot precompile header: code
in header". I encounter this when I declare default values
in constructs. When this happens, is precompilation really
a feature? Hmmm.


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
J

Jack Klein

Hi,

Can you actually compile header files? I'm writing a header file named
"test.h" using Visual C++ 6.0 and I get the following error message when I
try to compile it:

"no compile tool associated with this file extension".

Anyway, I thought the compiler will just do a syntax check, but it seems it
doesn't like it. Any comments appreciated.

side note: what does precompiled header mean?


Regards,
A

The reason that you can't compile a file named "test.h" with your
particular compiler has to do with the setup and features of your
particular compiler's IDE. There is nothing in the language that
prevents this, although of course your header might not be a complete,
valid translation unit on it's own.

Either ask in one of Microsoft's support groups on
msnews.microsoft.com to find out how to set your IDE to compile files
like this, or try from a command prompt and use the command line
compiler.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,372
Latest member
LucretiaFo

Latest Threads

Top