Jump to content
Eternal Lands Official Forums
hussam

some compiler warnings

Recommended Posts

Seems harmless as the build completes successfully but I thought I'd report them anyway

 

  CC   chat.o
chat.c: In function ‘put_string_in_input_field’:
chat.c:934:12: warning: operation on ‘msg->len’ may be undefined

 CC   pathfinder.o
pathfinder.c: In function ‘pf_destroy_path’:
pathfinder.c:195:27: warning: operation on ‘pf_visited_squares[i]’ may be undefined

CXX  io/elfilewrapper.o
io/elfilewrapper.cpp: In function ‘eternal_lands::el_file* eternal_lands::el_open(const char*)’:
io/elfilewrapper.cpp:32:51: warning: declaration of ‘eternal_lands::el_file* eternal_lands::el_open(const char*)’ with C language linkage
io/elfilewrapper.h:48:20: warning: conflicts with previous declaration ‘el_file* el_open(const char*)’
io/elfilewrapper.cpp: In function ‘eternal_lands::el_file* eternal_lands::el_open_custom(const char*)’:
io/elfilewrapper.cpp:45:58: warning: declaration of ‘eternal_lands::el_file* eternal_lands::el_open_custom(const char*)’ with C language linkage
io/elfilewrapper.h:58:20: warning: conflicts with previous declaration ‘el_file* el_open_custom(const char*)’
io/elfilewrapper.cpp: In function ‘eternal_lands::el_file* eternal_lands::el_open_anywhere(const char*)’:
io/elfilewrapper.cpp:58:60: warning: declaration of ‘eternal_lands::el_file* eternal_lands::el_open_anywhere(const char*)’ with C language linkage
io/elfilewrapper.h:68:20: warning: conflicts with previous declaration ‘el_file* el_open_anywhere(const char*)’
io/elfilewrapper.cpp: In function ‘eternal_lands::el_file* eternal_lands::el_open_no_decompress(const char*)’:
io/elfilewrapper.cpp:71:65: warning: declaration of ‘eternal_lands::el_file* eternal_lands::el_open_no_decompress(const char*)’ with C language linkage
io/elfilewrapper.h:77:20: warning: conflicts with previous declaration ‘el_file* el_open_no_decompress(const char*)’
io/elfilewrapper.cpp: In function ‘int eternal_lands::el_read(eternal_lands::el_file*, int, void*)’:
io/elfilewrapper.cpp:84:62: warning: declaration of ‘int eternal_lands::el_read(eternal_lands::el_file*, int, void*)’ with C language linkage
io/elfilewrapper.h:89:12: warning: conflicts with previous declaration ‘int el_read(el_file*, int, void*)’
io/elfilewrapper.cpp: In function ‘int eternal_lands::el_seek(eternal_lands::el_file*, int, int)’:
io/elfilewrapper.cpp:97:65: warning: declaration of ‘int eternal_lands::el_seek(eternal_lands::el_file*, int, int)’ with C language linkage
io/elfilewrapper.h:103:12: warning: conflicts with previous declaration ‘int el_seek(el_file*, int, int)’
io/elfilewrapper.cpp: In function ‘int eternal_lands::el_tell(eternal_lands::el_file*)’:
io/elfilewrapper.cpp:110:38: warning: declaration of ‘int eternal_lands::el_tell(eternal_lands::el_file*)’ with C language linkage
io/elfilewrapper.h:113:12: warning: conflicts with previous declaration ‘int el_tell(el_file*)’
io/elfilewrapper.cpp: In function ‘int eternal_lands::el_get_size(eternal_lands::el_file*)’:
io/elfilewrapper.cpp:123:42: warning: declaration of ‘int eternal_lands::el_get_size(eternal_lands::el_file*)’ with C language linkage
io/elfilewrapper.h:123:12: warning: conflicts with previous declaration ‘int el_get_size(el_file*)’
io/elfilewrapper.cpp: In function ‘void eternal_lands::el_close(eternal_lands::el_file*)’:
io/elfilewrapper.cpp:136:40: warning: declaration of ‘void eternal_lands::el_close(eternal_lands::el_file*)’ with C language linkage
io/elfilewrapper.h:132:13: warning: conflicts with previous declaration ‘void el_close(el_file*)’
io/elfilewrapper.cpp: In function ‘void* eternal_lands::el_get_pointer(eternal_lands::el_file*)’:
io/elfilewrapper.cpp:146:47: warning: declaration of ‘void* eternal_lands::el_get_pointer(eternal_lands::el_file*)’ with C language linkage
io/elfilewrapper.h:143:14: warning: conflicts with previous declaration ‘void* el_get_pointer(el_file*)’
 CXX  io/elfile.o

Share this post


Link to post
Share on other sites

I don't get these on gcc version 4.4.3 or 4.4.5. Which compiler/OS combination are you using? I've fixed the first couple as they were reasonably obvious but the elfilewrapper warnings are more tricky.

Share this post


Link to post
Share on other sites

hussam uses the awesome and bleeding edge Arch Linux which if he sync'd with repo recently will be on gcc 4.5.2

 

i should rly let him answer but couldn't resist plugging mi distro :> ;p

Edited by Korrode

Share this post


Link to post
Share on other sites

hussam uses the awesome and bleeding edge Arch Linux which if he sync'd with repo recently will be on gcc 4.5.2

 

i should rly let him answer but couldn't resist plugging mi distro :> ;p

Well, what a coincidence. I've currently configuring a fresh install of Arch Linux in a virtual machine. This is the first time I've tried it. :P

Share this post


Link to post
Share on other sites

hussam uses the awesome and bleeding edge Arch Linux which if he sync'd with repo recently will be on gcc 4.5.2

 

i should rly let him answer but couldn't resist plugging mi distro :> ;p

Well, what a coincidence. I've currently configuring a fresh install of Arch Linux in a virtual machine. This is the first time I've tried it. :P

You'll love it, bluap. startup daemons are easy to configure in /etc/rc.conf and pacman (the package manager) is very nice :)

Share this post


Link to post
Share on other sites

I don't get these on gcc version 4.4.3 or 4.4.5. Which compiler/OS combination are you using? I've fixed the first couple as they were reasonably obvious but the elfilewrapper warnings are more tricky.

 

I get those also using GCC 4.5.2 on OpenSuse.

 

Just to check if I'm on the right track:

as I see it, these warnings are caused by the use of namespace eternal_lands, and the use of this code by both C and C++ code:

the elfilewrapper.h header file always declares the functions in the global namespace (necessary, as C doesn't know about namespaces)

the elfilewrapper.c implementation always declares the functions in the eternal_lands namespace, but with C linkage;

 

this means that the functions appear to be in the global namespace in the object file (so linking works as expected),

but for the C++ compiler there are 2 declarations for each function:

the one in the header in global namespace (e.g. el_open(...) )

the one in the .cpp in the eternal_lands namespace (e.g. eternal_lands::el_open(...) )

these two symbols are different, and the compiler can't be sure they refer to the same function => conflict => warning.

 

And you cannot just add a (conditional) 'namespace eternal_lands' to the header either... (compilation errors!)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×