Article View: nl.comp.programmeren
Article #721Opbouw grote programma's via opsplitsing source-files
From: Bart Vandewoestyne
Date: Sat, 06 Nov 1999 00:00
Date: Sat, 06 Nov 1999 00:00
56 lines
2508 bytes
2508 bytes
Aangezien ik van plan ben om een grote applicatie te schrijven gebruik
makend van de GTK bibliotheek in Linux wil ik me toch eerst informeren
hoe je een groot programma best aanpakt.
Doe ik het bijvoorbeeld best op volgende manier (voorbeeldsituatie):
In de main.c komt:
#include "sub.h"
int main(void)
{
printf("Hoofdfile\n");
zetboodschap();
}
Dan maak ik een header file sub.h aan met volgende inhoud:
#include "sub.c"
void zetboodschap(void);
en in mijn sub.c komt dan te staan:
void zetboodschap(void)
{
printf("Subfile\n");
}
Nu is mijn vraag ook: stel dat ik bijvoorbeeld gebruik maak van
<stdio.h> en dat ik die header file nodig heb in verschillende .c
files. Moet ik deze dan in elk van die .c files includen ? Of waar
include ik ze dan best?
Ik heb het uitgeprobeerd en dit boeltje compileert zonder problemen via:
gcc -o main main.c
Indien mijn programma uit meerdere files bestaat, kan ik dan toch
compileren met ��n enkele regel in te typen? Kan iemand me dan kort
uitleggen waarom 'MakeFiles' bestaan? Kan ik inderdaad met die ene
regel compileren of maak ik best zo'n MakeFile aan?
Alvast bedankt,
MC303
--
Bart Vandewoestyne http://hello.to/MC303
Hugo Verrieststraat 48 Bart.Vandewoestyne@skynet.be
8550 ZWEVEGEM ICQ# 21275340
BELGIUM - EUROPE nick: MC303
Phone: +32(0)56/75.48.11
-------------------------------------------------------------------
If carpenters made buildings the way programmers make programs, the
first woodpecker to come along would destroy all of civilization.
- Weinberg's Second Law -
Technical Details
Message-ID:
<38249DCC.ABDE8533@skynet.be>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII X-Google-Thread: 100a19,bea50703bd2c4537,start X-Google-Attributes: gid100a19,public X-Google-Thread: 107324,bea50703bd2c4537,start X-Google-Attributes: gid107324,public X-Google-Thread: fcea4,bea50703bd2c4537,start X-Google-Attributes: gidfcea4,public From: Bart Vandewoestyne <Bart.Vandewoestyne@skynet.be> Subject: Opbouw grote programma's via opsplitsing source-files Date: 1999/11/06 Message-ID: <38249DCC.ABDE8533@skynet.be> X-Deja-AN: 545323781 Content-Transfer-Encoding: 8bit X-Accept-Language: nl-BE, nl, en, de Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@skynet.be X-Trace: news0.skynet.be 941923905 20695 194.78.239.135 (6 Nov 1999 21:31:45 GMT) Organization: MyHome Mime-Version: 1.0 NNTP-Posting-Date: 6 Nov 1999 21:31:45 GMT Newsgroups: nl.comp.programmeren,be.comp.programming,be.comp.os.linux