Mail Archives: djgpp/2000/03/07/17:08:57
Thanks for your answer. I'm going to test it right now, and my 60Ko source
file will become more readable !!
Hans-Bernhard Broeker <broeker AT acp3bf DOT physik DOT rwth-aachen DOT de> a écrit dans le
message : 8a12o7$j2r$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE...
> Cyberdivad <cyberdivad AT caramail DOT com> 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 <stdlib.h>
> > #include <stdio.h>
> > #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.
- Raw text -