Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I usually create one source file (main.c, for example) and one header file for that source file (main.h). In the source file, I put all the main sort of "interface" functions that I use in that file (in main, it'd be <code>main()</code>), and then whatever functions I get after refactoring those functions (implementation details), go below. In the header file, I declare some <code>extern</code> functions which are defined in other source files, but used in the source file which uses that header. Then I declare whatever structs or other data types that I use in that source file.</p> <p>Then I just compile and link them all together. It stays nice and clean. A typical include ... section, in my current project looks like this</p> <pre><code>#include&lt;windows.h&gt; #include&lt;windowsx.h&gt; #include&lt;stdio.h&gt; #include"interface.h" #include"thissourcefile.h" //function prototypes //source </code></pre> <p>there's an <code>interface</code> header which keeps track of the data structures I use in all of the forms in the project, and then <code>thissourcefile.h</code> which does exactly what I just explained (declares <code>externs</code>, etc).</p> <p>Also, I never define anything in my headers, I only put declarations there. That way they can be included by different source files and still link successfully. Function prototypes (extern, static, or otherwise) and declarations go in the header, that way they can be used lots of times--definitions go in the source, because they only need to be in one place.</p> <p>This would obviously be different if you were creating a library, or something like that. But just for internal project linking, I find this keeps everything nice and clean. Plus, if you write a makefile, (or you just use an IDE), then compiling is really simple and efficient.</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.
    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