hi, i m sourabh....... Can any1 tell me how to create a header file in c/c++
how to create header files in c/c++
Collapse
X
-
Tags: None
-
The text file doesn't even need the .h you just need to #include the text file in your source file.Comment
-
Exactly what the above guys said...
A typical example of a header file named Example.h is:
Note that if you want to be strictly ANSI the above code is wrong!!! Visual Studio gives an error and gcc a warning. And the reason is the last comment...Code:#ifndef EXAMPLE_H #define EXAMPLE_H /* make definitions, declarations here... */ #endif /* EXAMPLE_H */
Comment
-
I'll bite. My Visual Studio sees no error.Originally posted by Tassos SourisNote that if you want to be strictly ANSI the above code is wrong!!! Visual Studio gives an error and gcc a warning. And the reason is the last comment...Comment
-
Visual Studio gives an error as i said only with ANSI. You must put the /Za flag.Originally posted by weaknessforcatsI'll bite. My Visual Studio sees no error.
Specifically, the error is:
and that is because the logical source does not end with a new-line.. something like that..Code:fatal error C1004: unexpected end-of-file found
Comment
-
Yes, the file must end with a null record. That is, enter-key only.
I don't know exactly what the ANSI standard says about this.Comment
-
The C99 Standard:Originally posted by weaknessforcatsYes, the file must end with a null record. That is, enter-key only.
I don't know exactly what the ANSI standard says about this.
By 'splicing' they mean the trailing backslash immediately followed by a new-lineOriginally posted by C995.1.1.2. Environment
A source file that is not empty
shall end in a new-line character, which shall not be
immediately preceded by a backslash character before
any such splicing takes place.
character which concatenates two physical lines.
kind regards,
JosComment
-
I actually thought this was a bug in Visual Studio 2008 and asked a friend to send a bug report; the answer we got amazed us!!! :-PComment
-
I worked on a multi-platform project once where a new platform was introduced and its compiler produced an error where source files did not end in new-line. The compilers on the 3 existing platforms did not produce an error or even a warning in this case so lots of the code files did not end in a new-line.
Some lucky person (not me) got the job of adding a new-line to the end of all the (several 100) source files.Comment
Comment