Create own library of C functions
NickName:tnknepp Ask DateTime:2017-06-09T19:48:12

Create own library of C functions

I have been learning C for a couple weeks now (off and on). My primary use will be data analysis. I am surprised to find that simple functions are not available in the standard math.h library (e.g. average, mode, variance, etc.). Granted, these functions are simple enough to write, but doing so EVERY time they are needed is cumbersome.

I could write my own header file (call it my_math.h) to store all of the non-standard functions, and include this file as needed. I have two questions:

  1. If I create a header file, how do I point my compiler to it? Obviously, I would not want to have to copy the .h file to each project's directory.

  2. Am I reinventing the wheel here? Is there a standard library that has all of these functions pre-built?

Copyright Notice:Content Author:「tnknepp」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/44457019/create-own-library-of-c-functions

Answers
rbcvl 2017-06-09T11:57:26

The easiest way to do that is by using a Makefile which makes the link between your *.c and your *.h. \nYou have to declare your functions' headers into the *.h.\nYou can find some pieces of information here : \nMakefile include header .",


More about “Create own library of C functions” related questions

Create own library of C functions

I have been learning C for a couple weeks now (off and on). My primary use will be data analysis. I am surprised to find that simple functions are not available in the standard math.h library (e.g.

Show Detail

Procedure to include own functions to ANSI C Standard library

How one can include his/her own programming functions to standard C (ANSI C) library? And any one who is learning or working on C language able to use those functions anywhere anytime, no need of

Show Detail

Custom C library: can functions in the same library refer to each other?

I've just started to create my own C libraries to keep my commonly used functions tidy. However, I've hit a new problem and I struggled to find information on the best route to take. I generate my

Show Detail

Create a library and then redefine a function in main , C

Can I create my own library and redefine a function in main.c? I mean , for example: I create a library with 4 functions in which one is called Hash(void* parameter) <- generic parameter. I need...

Show Detail

Create Your Own Console Graphics Library in C

What I need to create is something simila to the CRT unit in Pascal or the old Graphics.h in Turbo C++, I am using the MinGW compiler. Is there any way to implement the GotoXY,ClrScr,Sleep,'SetClr'...

Show Detail

How to create a library (Ansi C) with private functions in linux?

I am trying to create a library (static or shared) that has only a specified functionality accessible for those who use that library. If I generate the library as follows, all functions implemented...

Show Detail

Adding my own easing functions to javaScript library (Paper.js)

I want to extend the Paper.js library (https://github.com/paperjs/paper.js) to add my own easing functions. The full source code of the library is here: https://cdnjs.cloudflare.com/ajax/libs/paper...

Show Detail

How to create my own String functions in C?

I am trying to create my own string function and I seem to be stuck at this point. Below is what I have so far to make a string and print it and return the size. But I need to make a function that is

Show Detail

Call PHP runtime functions as a linked library from C

This question almost answers what I want to know: Is it possible to call PHP's C functions in a C program? Of course you can call PHP functions from C if you compile the PHP source code with y...

Show Detail

How to create a C library with CodeBlocks?

How can I create a C library in CodeBlocks that can be define and used like a standard library with the #include command? In fact I want to create a simple library that is Composed of several func...

Show Detail