NO

Author Topic: where to place user created library function files  (Read 3509 times)

elias001

  • Guest
where to place user created library function files
« 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

« Last Edit: February 26, 2014, 06:54:11 PM by elias001 »

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: where to place user created library function files
« Reply #1 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 ;-)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: where to place user created library function files
« Reply #2 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).
« Last Edit: February 27, 2014, 10:23:41 AM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: where to place user created library function files
« Reply #3 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.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: where to place user created library function files
« Reply #4 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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

elias001

  • Guest
Re: where to place user created library function files
« Reply #5 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.