Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't create C header file to be accessible from my programs
    primarykey
    data
    text
    <p>I made up my project, saved main and c source in one file, and saved the header file in the include directory of codeblocks. When I call my functions from within the project main function, it compiles beautifully.. but when I <code>#include</code> the header to other files for use, the compiler cannot find the functions. The prototypes are in the header, but their definition is in the source code which is in another file. I can access preprocessor constants and macros stored in the header, but the link between the function prototypes and their source code seems not to exist outside the actual project.</p> <p>My goal was to make header files just like the existing ones I was using (stdio.h, stdlib.h, etc.). I can't find anything helpful on that anywhere. Help me, I've been at this for days!</p> <p>I know I can make .c files with functions which is way easier, but I want the challenge, want to create lib files, and I'm a performance freak (as far as I know using .h files instead of .c files is much more efficient, can't remember why, though.)</p> <p>header file:</p> <pre><code> #ifndef FIRO_H_INCLUDED #define FIRO_H_INCLUDED #include &lt;stdbool.h&gt; #define MA_TA 69 bool checkprime(unsigned long long); int square(int); #endif // FIRO_H_INCLUDED </code></pre> <p>source code:</p> <pre><code> #include "firo.h" #include &lt;math.h&gt; bool checkprime(unsigned long long prime) { unsigned long long root=(unsigned long long)(sqrt(prime)+1); unsigned long long i; for(i=2; i&lt;=root; i&lt;3?(i++):(i+=2)) { if(prime%i==0) return false; } return true; } int square(int a) { return a*a; } </code></pre> <p>I was hoping for an answer, not irony. I did read somewhere that segmenting code into .h files and source codes separately would somehow dinamically speed up the process of accesing functions, don't blame me for not knowing how that works. The checkprime function I actualy use, the rest is just for testing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload