[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-ppc
Subject: RE: Compile problems
From: Steve Revilak <revilak () umbsky ! cc ! umb ! edu>
Date: 2000-07-10 20:18:01
[Download RAW message or body]
> Careful. If the declartion in the .h file is "extern," then the
> problem will remain. If the delcaration in the .h file isn't
> "extern," then multiple definitions will occur and the linker will
> now complain about that unacceptable situation.
Okay, I should have been clearer. You though I had meant something other
than what I thought had I meant :-)
I'll be more explicit:
/* testh.h */
#ifndef TEST_H
#define TEST_H
int a;
void testfun(void);
#endif
/* test1.c */
#include <stdio.h>
#include "test.h"
int main(void) {
printf("Hello world\n");
a=2;
testfun();
a=4;
testfun();
return 0;
}
/* test2.c */
#include <stdio.h>
#include "test.h"
void testfun(void) {
printf("Now got into testfun\n");
printf("a = %i\n",a);
}
% gcc -Wall -ansi test1.c test2.c -o test
% ./test
Hello world
Now got into testfun
a = 2
Now got into testfun
a = 4
** Sent via the linuxppc-user mail list. See http://lists.linuxppc.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic