473,799 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

resolution of references by the compiler/linker

Hi Everyone,

I was wondering if references to a function defined in another file
is resolved at linker time, why isn't the same extended for global
variables? I mean, without the extern keyword being used... does the
standard say that reference to global variables have to be resolved at
compile time?

Thanks in advance!!!
Jan 5 '08 #1
2 1133
Rahul wrote:
Hi Everyone,

I was wondering if references to a function defined in another file
is resolved at linker time, why isn't the same extended for global
variables? I mean, without the extern keyword being used... does the
standard say that reference to global variables have to be resolved at
compile time?
Declaring a variable extern is what makes it a global.

--
Ian Collins.
Jan 5 '08 #2
On Jan 5, 3:20 pm, Ian Collins <ian-n...@hotmail.co mwrote:
Rahul wrote:
Hi Everyone,
I was wondering if references to a function defined in another file
is resolved at linker time, why isn't the same extended for global
variables? I mean, without the extern keyword being used... does the
standard say that reference to global variables have to be resolved at
compile time?

Declaring a variable extern is what makes it a global.

--
Ian Collins.
Sorry wanted to post in comp.lang.c where compiler assumes that a
undeclared function would return an int and would be defined in some
other compilation unit... c++ makes sure that a prototype is very much
necessary for a function call...
Jan 5 '08 #3

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

Similar topics

1
1311
by: Srikanth Madani | last post by:
Hi all, Suppose I have a C file fun1.c containing two functions: __________ void func1() { printf("\nIn function func1()\n"); } void func2() { func3(); }
5
3542
by: lars.uffmann | last post by:
Hi - since my Suse 10.1 didn't have netcdf support enabled by default, I downloaded the sources from http://www.unidata.ucar.edu/software/netcdf/ then did ../configure --prefix=/usr make make test --succeeded make extra_test --succeeded make install In my /usr/include I now have the files
6
1461
by: Rahul | last post by:
Hi Everyone, when a call to a function is done in a file and if the function isn't defined, compiler just assumes that it would return a int and that the definition would be available at some other compilation unit which should be given to the linker to generate the executable file. However, why doesn't this extend to a global variable which isn't declared? The compiler gives as error immediately...
5
3308
by: VanKha | last post by:
Hi everyone , I've just read a book on Computer Systems.(Computer Systems:A programmer's perspective ) . On the part of "Linking" , the author talks about strong/weak symbol and as an example for the rule "Given a strong symbol and weak symbols , choose the strong one" , he gives the following C modules /* foo5.c */ #include<stdio.h> void f(); int x=15213,y=15212; int main() { f();
0
9689
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10495
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10248
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2942
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.