New style header files?

P

Protoman

I have this file: example.hpp
Will Dev-Cpp (or any other compiler) accept this?: #include "cexample"
Thanks!!!
 
W

W Marsh

I have this file: example.hpp
Will Dev-Cpp (or any other compiler) accept this?: #include "cexample"
Thanks!!!

If the file cexample exists! What does example.hpp have to do with it?

#include does exactly what it says on the tin.
 
A

Andre Kostur

If the file cexample exists! What does example.hpp have to do with it?

#include does exactly what it says on the tin.

The OP is probably getting confused with what:
#include <string.h>
and
#include <cstring>

Have to do with each other, and does it apply to user-supplied include
files (such as example.hpp).

Answer is... no, if you don't supply a file extension on the #include
statment, the compiler (or at least no compiler that I am aware of) will
not automatically add _anything_ to the filename. It will attempt to
include exactly the name you specified.
 
P

Protoman

Andre said:
The OP is probably getting confused with what:
#include <string.h>
and
#include <cstring>

Have to do with each other, and does it apply to user-supplied include
files (such as example.hpp).

Answer is... no, if you don't supply a file extension on the #include
statment, the compiler (or at least no compiler that I am aware of) will
not automatically add _anything_ to the filename. It will attempt to
include exactly the name you specified.

Then can I name the file "cexample"? and it'll work?
 
B

BobR

Protoman wrote in message
Then can I name the file "cexample"? and it'll work?

Did you try it?
(BTW: sex is spelled s e x, not c e x.)

You can name the file "myfunkybutt.someslinkyextension" and do:
#include "myfunkybutt.someslinkyextension"

Dev-C++ uses the MinGW port of GCC. Read the GCC docs to see which file
extensions have special meaning.
Look in the '*\include' directory for the 'C' headers.
Look in the '*\include\c++\<ver. number (3.3.1)>" for the 'C++' headers.
Go to the C++ includes directory and open the "cstring' header, you'll see
it refer to the 'string.h' C header, and do some stuff to make it work in C++
(if needed).
 
A

Andre Kostur

Then can I name the file "cexample"? and it'll work?

Yes, but I'd wonder why you'd want to have an extensionless file....
it's generally handy to konw if a source file is intended to be used as
a header file or not..
 

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

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top