Pelles C forum

C language => Beginner questions => Topic started by: elias001 on February 26, 2014, 06:29:25 PM

Title: where to place user created library function files
Post by: elias001 on February 26, 2014, 06:29:25 PM
Hello all,

I have a quick question, if i like to created my own library function file with the *.h extension, I am not sure if that is the right term, after that, where do i place it.

What i am referring to is in the beginning of every C program, you have the following


#include (stdio.h>

but if i write my own and call it ABC.h, i would do the following:

#include "ABC.h"

But the ABC.h file, where in the Pelles C installed directory do I place the file. 

Thanks in advance

Title: Re: where to place user created library function files
Post by: jj2007 on February 26, 2014, 07:37:50 PM
You can place it in any folder that the compiler can find. However, placing it with the "official" header files might cause confusion, therefore it might be better to place it
a) in the project's folder (but then it will be useful only for that particular project) or
b) in a special folder ..\\MyHeaders
Test it ;-)
Title: Re: where to place user created library function files
Post by: frankie on February 27, 2014, 09:28:50 AM
The Syntax
Code: [Select]
#include <somefile.h>states that the file resides in the compiler headers directory (generally used only for compiler related files).
The compiler automatically look in the compiler include folder for these files. The base directory is the compiler include directory.
On the other hand the syntax
Code: [Select]
#include "somefile.h"Means that the file is not strictly part of the compiler or the language, but is a user or third part file.
The base dirctory is considered the same where the including source resides.
Such files can be everywhere you like.
Note that you can specify the directory
Code: [Select]
#include "../OneLevelAboveCodeFile.h"
#include "MyBaseDirectory/Mysubdirectory/Myfile.h"
Only take care to use slash '/', and not the standard MS backslash '\', to separate file parts (Unix syntax).
Title: Re: where to place user created library function files
Post by: jj2007 on February 27, 2014, 10:22:09 AM
Only take care to use slash '/', and not the standard MS backslash '\', to separate file parts (Unix syntax).

Double backslash works, too.
Title: Re: where to place user created library function files
Post by: frankie on February 27, 2014, 10:25:34 AM
Double backslash works, too.
As JJ pointed out you can also use double backslash because the file name is treated as a string and use the string escaping.
Title: Re: where to place user created library function files
Post by: elias001 on February 28, 2014, 12:06:06 AM
Okay thanks guys.

I have one last question, where do i place a "makefile" and any file with extension *.shar.   Thanks again.