ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I do not use the "static" keyword in either place.
The latest version of gcc for my i686 machine (Debian stable) is 4:4.7.2-1. The current for my AMD64 machine is 4:4.8.2-4
This program has compiled without error on the AMD64 for the past year.
Why is the 4:4.7.2-1 giving me static (sic), and how do I get it to compile?
Quote:
Originally Posted by smallpond
It's saying that your actual code has the "static" keyword in one place but not the other:
doit() is declared twice: once as a placeholder, and the second time with its 230 lines of code. The placeholder is necessary since I have interlocking subroutines.
doit() gets called whenever a mouse gets clicked. It sorts out which window (of currently about a dozen) was under the mouse when it got clicked, and then calls the appropriate subroutine for execution of the mouse-picked function. Note: doit() is not static and not recursive: It is called the first time per mouse click on the main window, whereupon it creates an appropriate subwindow. It then goes away until the mouse is clicked on that subwindow. Think of doit() as a universal state monitor. Including header files, the program is currently up to ~7000 lines of C & OpenGL, and growing.
Quote:
Originally Posted by metaschima
Are you sure 'doit()' is only declared once in your program (check other files as well).
Either rename the doit function or make it static (prototype and declaration). I suspect it may be declared in an include file somewhere. If you make it static it will override the previous declaration. Not the best solution, renaming it would be better.
See bug report http://gcc.gnu.org/ml/gcc-bugs/2004-12/msg00415.html
The declaration of a function should match the prototype of that declaration. I am seeing that bug error in gcc 4:4.7.2-1 but not 4:4.8.2-4
In other words, it is a compiler error, not a coding error.
So, this function was declared as 'static' even if you stated otherwise in #3.
The definition and the declaration should be identical, even if some compilers (or compiler versions) don't give error if they aren't.
1. either "static void doit()" or "void static doit()" results in an error message, "invalid storage class for function doit". Apparently this is a bug: http://www.geeksforgeeks.org/what-ar...unctions-in-c/
2. Upon research, my use of the prototype of doit is not only acceptable practice, but is actually recommended. The bug appeared when gcc started requiring that the arguments of the prototype exactly match the arguments of the coded function. Gcc version 3.* allowed an empty argument field, which could be promoted by the coded version of the function.
Quote:
Originally Posted by NevemTeve
So, this function was declared as 'static' even if you stated otherwise in #3.
The definition and the declaration should be identical, even if some compilers (or compiler versions) don't give error if they aren't.
See bug report http://gcc.gnu.org/ml/gcc-bugs/2004-12/msg00415.html
The declaration of a function should match the prototype of that declaration. I am seeing that bug error in gcc 4:4.7.2-1 but not 4:4.8.2-4
In other words, it is a compiler error, not a coding error.
The compiler error in that bug report is that the compiler fails to reject or at least warn about the code.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.