From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: make a faster blit (allegro) Date: 6 Mar 2000 20:00:07 GMT Organization: Aachen University of Technology (RWTH) Lines: 62 Message-ID: <8a12o7$j2r$1@nets3.rz.RWTH-Aachen.DE> References: <200003050219 DOT HAA01019 AT midpec DOT com> <8a0tfo$aaf$1 AT wanadoo DOT fr> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 952372807 19547 137.226.32.75 (6 Mar 2000 20:00:07 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 6 Mar 2000 20:00:07 GMT User-Agent: tin/1.4-19991113 ("No Labels") (UNIX) (Linux/2.0.0 (i586)) Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Cyberdivad wrote: > Here is an example of source with the project file for rhide. This example > work only if you don't setup variables with values (like a=2;). > In this example, this is not really a problem, but my program needs to > assign values to var in header files. Then your idea of how C programming works must be wrong. What makes you think it makes a difference for *you* (or your program), where that initialization is? In other words, why would your program 'need' that? It sure does make a difference to the C compiler and linker, as defined by the programming language inventors, so you'll have to follow their rules, rather than your personal preferences. I'll show you how to modify it to get a working C program. > source of header f.h : > #include > #include > #include "allegro.h" > #ifndef FONC_H > #define FONC_H > // here Change these two: > int d_a=10; > int d_b=11; into: extern int d_a; extern int d_b; > extern int calcab(int a, int b); > #endif > ---------------- > source of f.c : > #include "fonc.h" Add two lines, here: int d_a=10; int d_b=11; > int calcab(int a, int b) > { > return a*b+d_a; > } > -------------- [...] Once you've checked that it works, now, go back to your C textbook and read up on how to organize a program into multiple source files. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.