Pelles C forum

C language => Beginner questions => Topic started by: butaphantom on March 19, 2025, 03:00:37 AM

Title: Can't add .h tomproject
Post by: butaphantom on March 19, 2025, 03:00:37 AM
i can add .c to project ,but when i add .h it doesn't work
Title: Re: Can't add .h tomproject
Post by: DMac on March 19, 2025, 04:50:11 AM
Hi Mr Phantom,

At the top of your .c file add

#include "myheader.h"

or

#include <windows.h>

And then right click on your project and select update dependencies.

(about:invalid)
Title: Re: Can't add .h tomproject
Post by: butaphantom on March 19, 2025, 05:28:26 AM
Thanks!

But i think i was wrong about the description. It's not that it doesn't work.

I meant that i can't add .h files in the  resource management right of window. If I want to modify an .h file, do I have to find it in Windows Explorer?
Title: Re: Can't add .h tomproject
Post by: TimoVJL on March 19, 2025, 07:21:31 AM
You have to close resource editor and then open rc-file as text
Right mouse button -> Open as -> Text
Title: Re: Can't add .h tomproject
Post by: John Z on March 19, 2025, 08:43:55 AM
Hi butaphantom,

Quote from: butaphantom on March 19, 2025, 03:00:37 AMi can add .c to project ,but when i add .h it doesn't work

To add an existing .h file to your project and have it show up in the sources pane
the .h file name must be entered into the .c source file as DMac mentioned.

To do that you use a statement that looks like this:
#include <stdio.h>    <----- for system includes
OR a statement that looks like this:
#include "myfile.h"    <-----  for includes specifically for your project.

If you need to create the .h file use File - New - Source Code and save the
file with .h extension in your project directory.  After that add the
#include "my_h_file_name.h" to your C source(s) as needed.

Hope this clarifies how to add a .h file to your project. 
Also I'll mention that only .h files you make for your project (those in quotes) will show in the window.
System .h files will not show up there since you should not be editing them.....

John Z 👍
Title: Re: Can't add .h tomproject
Post by: butaphantom on March 19, 2025, 11:16:49 AM
Thanks everybody!
 like your sad, i try it, i made it
: )