473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Query regarding warning removal when using extern

I am facing a problem with warning removal
I have got a header file it contains extern declarations of lot of
variables (say 100)
This header file is included in hundreds of .c files. Some of these .c
file contain definition of one the variable declared as extern in
header file. But since the header file is also included in this .c file
containing definition of variable, the compiler gives a warning . The
header file is common to hundreds of files ,so it is not possible to
remove extern declaration of variable from it, as it might be required
in other files.
Now my task is to remove these kind of warnings where a variable is
defined in the file and its extern is also declared in header file
included in this file. The code size is running into lakhs of lines.

Jul 18 '06 #1
4 1887

ga*********@gmail.com wrote:
I am facing a problem with warning removal
I have got a header file it contains extern declarations of lot of
variables (say 100)
This header file is included in hundreds of .c files. Some of these .c
file contain definition of one the variable declared as extern in
header file. But since the header file is also included in this .c file
containing definition of variable, the compiler gives a warning . The
header file is common to hundreds of files ,so it is not possible to
remove extern declaration of variable from it, as it might be required
in other files.
Now my task is to remove these kind of warnings where a variable is
defined in the file and its extern is also declared in header file
included in this file. The code size is running into lakhs of lines.
Um that shouldn't give a warning.

----
tom@bigbox ~ $ cat test.c
extern int a;

int a;
tom@bigbox ~ $ gcc -O2 -Wall -W -c test.c
----

Maybe your code gives warnings because you modify the type? e.g.

extern long a;

int a;

That will cause problems.

Or

extern long *a;

long a[100];

Will cause problems.

Tom

Jul 18 '06 #2
ga*********@gmail.com (in
11*********************@h48g2000cwc.googlegroups.c om) said:

| I am facing a problem with warning removal
| I have got a header file it contains extern declarations of lot of
| variables (say 100)
| This header file is included in hundreds of .c files. Some of
| these .c file contain definition of one the variable declared as
| extern in header file. But since the header file is also included
| in this .c file containing definition of variable, the compiler
| gives a warning . The header file is common to hundreds of files
| ,so it is not possible to remove extern declaration of variable
| from it, as it might be required in other files.
| Now my task is to remove these kind of warnings where a variable is
| defined in the file and its extern is also declared in header file
| included in this file. The code size is running into lakhs of lines.

The easy way is to remove the variable declaration from the file that
produces the warnings; and create a separate source file containing
the declaration. This will increase the linker workload but make the
compiler much happier.

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto
Jul 18 '06 #3


ga*********@gmail.com wrote On 07/18/06 13:34,:
I am facing a problem with warning removal
I have got a header file it contains extern declarations of lot of
variables (say 100)
This header file is included in hundreds of .c files. Some of these .c
file contain definition of one the variable declared as extern in
header file. But since the header file is also included in this .c file
containing definition of variable, the compiler gives a warning . The
header file is common to hundreds of files ,so it is not possible to
remove extern declaration of variable from it, as it might be required
in other files.
Now my task is to remove these kind of warnings where a variable is
defined in the file and its extern is also declared in header file
included in this file. The code size is running into lakhs of lines.
There is nothing wrong with declaring a variable with
the `extern' qualifier in the same compilation where that
variable is defined:

extern int fuzzball; /* legal declaration */
int fuzzball = 42; /* legal definition */

There *is* something wrong if the declaration and the
definition disagree:

extern char *string; /* legal declaration */
char string[100]; /* legal definition */
/* ... but the two are inconsistent, so the
* compiler will complain.
*/

What is the text of the warning message? Can you post
some actual code (shorter than lakhs of lines) that causes
the compiler to emit the message?

--
Er*********@sun.com

Jul 18 '06 #4
ga*********@gmail.com writes:
I am facing a problem with warning removal
I have got a header file it contains extern declarations of lot of
variables (say 100)
This header file is included in hundreds of .c files. Some of these .c
file contain definition of one the variable declared as extern in
header file. But since the header file is also included in this .c file
containing definition of variable, the compiler gives a warning . The
header file is common to hundreds of files ,so it is not possible to
remove extern declaration of variable from it, as it might be required
in other files.
Now my task is to remove these kind of warnings where a variable is
defined in the file and its extern is also declared in header file
included in this file. The code size is running into lakhs of lines.
A "lakh" is 100,000. (The term isn't widely used outside India.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: William Payne | last post by:
Ok, in my program I have a std::list<Document*>, where Document is one of my own classes. I need to go through this list and check each item if it's ready for deletion. If it's not, skip to...
3
by: Eric Lilja | last post by:
Hello, I have a few global variables in my program. One of them holds the name of the application and it's defined in a header file globals.hpp (and the point of definition also happen to be the...
9
by: tropostropos | last post by:
On Solaris, using the Sun compiler, I get annoying warnings from the following code. The problem is that I am passing a C++ member function pointer to the C library function qsort. Is there a...
10
by: Rick Anderson | last post by:
All, I am receiving the following compilation error on LINUX (but not Solaris, HPUX, WIN32, etc): compiling osr.c LBFO.h(369): warning #64: declaration does not declare anything extern...
1
by: Siddharth Jain | last post by:
hello I am trying to enumerate the shared folders on a server using the NetShareEnum function. Now, when the server has a password set to access the shared folders, the function returns system...
6
by: Chad | last post by:
In the following code snippet, I declare the variable val as float in the calc.h header file, and define it as int in test.c. The question is, when I compile this with full warnings, I get no...
10
by: sam_cit | last post by:
Hi Everyone, I had a doubt regarding extern decleration, i tried this is one source file, extern int sample; extern int sample; int main() {
4
by: lucavilla | last post by:
If you go to http://europe.nokia.com/A4305060, fill the "Enter your product code:" field with the value "0523183" and press "Go" (the ending page URL varies because there's a variable session-ID in...
10
by: somenath | last post by:
Hi All, I have one question regarding return value cast of malloc. I learned that we should not cast the return value of malloc because it is bug hider. But my question is as mentioned...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.