|
-
Jan 13th, 2001, 02:42 AM
#1
Thread Starter
Addicted Member
Okay,
I just created a header file called "practice.h"
All it contain is
#define ERROR printf("\nError");
Then I go back to my source file and #include <practice.h>
but when I compile it cant locate it.
All files are in the same directory.
Any help.
(New to C )
Thanks
-
Jan 13th, 2001, 02:50 AM
#2
Lively Member
use this:
#include "practice.h"
when you enclose something in <> that means its going to look in your systems library, quotes means its going to look in the current directory
-
Jan 13th, 2001, 02:58 AM
#3
Thread Starter
Addicted Member
Thanks ExciteMouse,
Works great
-
Jan 13th, 2001, 07:37 AM
#4
Monday Morning Lunatic
Quick note on creating header files.
If you have another source file that also includes practice.h, then it will try and redefine ERROR. To prevent against this, all header files have a mechanism similar to this to make sure they're only included once by the compiler:
Code:
#ifndef __PRACTICE_H__
#define __PRACTICE_H__
/* Header contents */
#endif // __PRACTICE_H__
That last comment at the end isn't absolutely necessary, but it's good practice in preprocessor #if / #endif constructs to put them in, since they tend to contain large volumes of code.
[Edited by parksie on 01-13-2001 at 07:40 AM]
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 13th, 2001, 02:42 PM
#5
Lively Member
oh!
so THATS what all that crap means!
i always wondered about that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|