Nuno Carvalho wrote:
> Hi,
>
> I'm compiling my project on C language using the following Makefile:
>
> ------- cut here -------------------------------
> bbs : autenticacao.o idioma.o menus.o extrainfo.o
> gcc -lcrypt -lcurses -o bbs menus.o autenticacao.o idioma.o \
> extrainfo.o bbs.c
>
> idioma.o :
> gcc -c idioma.c
>
> autenticacao.o :
> gcc -c autenticacao.c
>
> extrainfo.o :
> gcc -c extrainfo.c
>
> menus.o :
> gcc -c menus.c
> clean :
> rm -f *.o *.core
> ------------ cut here -------------------------
I would recommend reading the Info file for `make', and looking at
some makefiles from real-world applications.
For starters, you don't need to specify explicit rules for each object
file. There is an implicit rule to make a .o from a .c using the
command:
$(CC) -c $(CPPFLAGS) $(CFLAGS) $@
where `$@' is the name of the .c file.
> Meanwhile when i try to compile it i've that:
>
> ---- cut here -------------
> nemanuel@cavern:~/bbs$ make
> gcc -c autenticacao.c
> gcc -c idioma.c
> gcc -c menus.c
> gcc -c extrainfo.c
> gcc -lcrypt -lcurses -o bbs menus.o autenticacao.o idioma.o extrainfo.o
> bbs.c
> bbs.c:29: warning: `ficheiros_BBS' initialized and declared `extern'
> nemanuel@cavern:~/bbs$
> ------cut here -------------
>
> Could someone tell me how can I remove that warning !?
>
> ficheiros_BBS's variable it's defined on bbs.c file as:
>
> extern char *ficheiros_BBS[] = {"/in/login", "in/logout", "in/register" };
Remove the `extern' keyword. You use `extern' to declare that a
particular variable will be defined by a different module. E.g. you
would use
extern char *ficheiros_BBS[];
in other source files which refer to ficheiros_BBS (typically you
would place all external variable declarations into header files).
> .... and I need to declare it!
>
>
> Even getting this warning I can compile my project! ;) Meanwhile it
> appears an error that I can't resolve it! :-(
>
> bbs.c is the main file and I need to call a function(main_menu()) on
> menus.c !
>
> on menu.c i've an idiom's variable declared as:
>
> char idiom[10];
>
> and main_menu() function from menu.c it's:
>
> main_menu(int client_desc, char *idiom )
>
> My problem is that when I call main_menu(client, idiom)(menus.c) from
> bbs.c(main file) and send idiom char array as second argument, main_menu()
> function get garbage on idiom variable and so don't get my string !:(((
> It's not sending my variable value ! :-( Or if it's it will erase it and
> copy into that trash.
>
> What could it be !?
This sounds like the problem which was discussed a couple of weeks
back in the thread entitled `Compiler problem?'. The file which calls
main_menu needs to have
extern char idiom[];
otherwise the compiler will act as if `idiom' was declared with
extern char *idiom;
The two are not compatible.
--
Glynn Clements <[EMAIL PROTECTED]>