hello,
To limit scope of a variable in a single file that is part of a
large project that have several C files we use static variable
right?then to limit any variable to function scope it should be
declared as auto or anything else? 14 2423
> To limit scope of a variable in a single file that is part of a large project that have several C files we use static variable right?
Right.
then to limit any variable to function scope it should be declared as auto or anything else?
auto is the default for local variables, you don't need to do anything
special if you want a variable to be local to a function, just declare
it inside the function. ra*******@gmail .com writes: To limit scope of a variable in a single file that is part of a large project that have several C files we use static variable right?then to limit any variable to function scope it should be declared as auto or anything else?
It seems that you are confusing scope and linkage. Any variable
declared outside a function has file scope, regardless of whether
it is declared with `static' or not. However, `static' gives the
variable internal linkage, which means that it will not be linked
against file-scope identifiers in other translation units.
Variables declared inside a function have block scope, not
function scope. (Only labels have function scope.) When they
are declared without a storage class specifier, or with any
storage class specifier other than `extern', they have no
linkage.
--
"It wouldn't be a new C standard if it didn't give a
new meaning to the word `static'."
--Peter Seebach on C99 ra*******@gmail .com wrote on 26/09/05 : To limit scope of a variable in a single file that is part of a large project that have several C files we use static variable right?then to limit any variable to function scope it should be declared as auto or anything else?
There is no 'function scope'. There is 'block scope'. A variable
defined in a block has the block scope. If it has the 'static'
qualifier, it becomes persistent.
But these methods are not encouraged, specially for large project.
Better to work with 'contexts', where data are defined in a structure,
and where the code is designed to process the data.
It's the first step to Object Oriented Programming, that is a Good
Thing.
Next step is 'ADT' (Abstract Data Types). Google is your friend.
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
"There are 10 types of people in the world today;
those that understand binary, and those that dont."
Emmanuel Delahaye wrote: ra*******@gmail .com wrote on 26/09/05 :
To limit scope of a variable in a single file that is part of a large project that have several C files we use static variable right?then to limit any variable to function scope it should be declared as auto or anything else? There is no 'function scope'.
There _is_ function scope.
Function scope is what labels are visible in.
There is 'block scope'. A variable defined in a block has the block scope. If it has the 'static' qualifier, it becomes persistent.
Right.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Michael Mair wrote on 26/09/05 : Emmanuel Delahaye wrote: ra*******@gmail .com wrote on 26/09/05 :
To limit scope of a variable in a single file that is part of a large project that have several C files we use static variable right?then to limit any variable to function scope it should be declared as auto or anything else?
There is no 'function scope'.
There _is_ function scope. Function scope is what labels are visible in.
There is 'block scope'. A variable defined in a block has the block scope. If it has the 'static' qualifier, it becomes persistent.
Right.
Cheers Michael
labels ? goto ? Sorry, I don't code in assembly nor in BASIC anymore
;-)
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
I once asked an expert COBOL programmer, how to
declare local variables in COBOL, the reply was:
"what is a local variable?"
Emmanuel Delahaye wrote On 09/26/05 15:33,: Michael Mair wrote on 26/09/05 :
Emmanuel Delahaye wrote:
ra*******@gm ail.com wrote on 26/09/05 :
To limit scope of a variable in a single file that is part of a large project that have several C files we use static variable right?the n to limit any variable to function scope it should be declared as auto or anything else?
There is no 'function scope'.
There _is_ function scope. Function scope is what labels are visible in.
There is 'block scope'. A variable defined in a block has the block scope. If it has the 'static' qualifier, it becomes persistent.
Right.
Cheers Michael
labels ? goto ? Sorry, I don't code in assembly nor in BASIC anymore ;-)
Do you write functions with non-empty argument lists?
-- Er*********@sun .com
Eric Sosman wrote on 26/09/05 : labels ? goto ? Sorry, I don't code in assembly nor in BASIC anymore ;-)
Do you write functions with non-empty argument lists?
Yes, I do.
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
I once asked an expert COBOL programmer, how to
declare local variables in COBOL, the reply was:
"what is a local variable?"
Eric Sosman <er*********@su n.com> writes: Emmanuel Delahaye wrote On 09/26/05 15:33,: Michael Mair wrote on 26/09/05 :
Emmanuel Delahaye wrote:
There is no 'function scope'.
There _is_ function scope. Function scope is what labels are visible in.
There is 'block scope'. A variable defined in a block has the block scope. If it has the 'static' qualifier, it becomes persistent.
labels ? goto ? Sorry, I don't code in assembly nor in BASIC anymore ;-)
Do you write functions with non-empty argument lists?
Irrelevant. "A label name is the only kind of identifier that
has function scope." (C99 6.2.1)
You are thinking of function prototype scope.
--
"Some people *are* arrogant, and others read the FAQ."
--Chris Dollin
<ra*******@gmai l.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. . hello, To limit scope of a variable in a single file that is part of a large project that have several C files we use static variable right?then to limit any variable to function scope it should be declared as auto or anything else?
Related - is it bad form to actually use 'auto' - is being explicit best? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jonathan |
last post by:
Hi,
I've read through quite a number of postings on here so far and have
seen what look like very simply, reasonable answers to this question,
however I am still completely unable to do what I want to do.
I just want to know how I should toggle the visibility of divs in
Netscape (I'm using 7). For example, say I have the following HTML
code:
|
by: Jukka K. Korpela |
last post by:
I have noticed that the meaning of visibility: collapse has been discussed
on different forums, but with no consensus on what it really means.
Besides, implementations differ.
The specification says:
"The 'visibility' property takes the value 'collapse' for row, row group,
column, and column group elements. This value causes the entire row or
column to be removed from the display, and the space normally taken up by
the row or column to...
|
by: lawrence |
last post by:
The following function correctly makes everything invisible but then
fails to turn the one chosen DIV back to visible. I imagine I'm
getting the syntax of the variable wrong? I've tried this with both
single quotes and no single quotes, but it doesn't work either way.
What am I doing wrong?
<SCRIPT type='text/javascript'>
function makeVisible(nameOfDiv) {
document.getElementById('weblogs').style.visibility='hidden';
|
by: lawrence |
last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in
IE???
<SCRIPT type='text/javascript'>
function makeVisible(nameOfDiv) {
document.getElementById(nameOfDiv).style.visibility='visible';
document.getElementById(nameOfDiv).style.height='auto';
if (nameOfDiv != 'weblogs')
|
by: Michael Sgier |
last post by:
Hello
i don't understand the visibility/passing of variables. I've in
texture.h:
class CTexture
{
public:
unsigned int texID;
GLuint texture;
| |
by: TTroy |
last post by:
I have a few questions about "scope" and "visibility," which seem like
two different things.
To me "visibility" of the name of a function or object is the actual
code that can use it in an actual program.
To me "scope" of the name of a function or object are the general rules
for the areas of a program that can through a declaration, have
"visibility."
|
by: Jim Heavey |
last post by:
Hello, I create a HTML line as follows:
<P class=text12BoldRed id=ErrTimePeriodSelection
style="VISIBILITY: hidden" runat="server">Selection of time period
either
not made or more then one type (Relative <EM>or</EM> specific time
period)
was selected</P>
I have javascript which performs an edit and turns the visibility on or off
|
by: -D- |
last post by:
How can I turn the visibility of the xml control on or off?
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<table cellSpacing="0" cellPadding="0" border="0">
<colgroup span="1" align="left" width="50%">
</colgroup>
<colgroup span="1" align="right" width="50%">
</colgroup>
|
by: jhullu |
last post by:
Hi all
I'm lookup for a documentation or explanation abour the visibility and
syntax about class.
I found the ECMAScript Language Spec. 3 (final) & 4 (draft) but it's
not very easy to read this doc...
I wish create a simple class with a constructor and a method using the
keyword 'this' but i've strange error.
|
by: BOMEz |
last post by:
So i've recently been starting to program PHP in an object oriented way, but I'm running into some difficulties in from a design stand point and from an object oriented stand point:
Issue 1: In my class I cannot give visibility to any variable, it simple breaks everything. For example if I do: private $private = 'Private'; I get the error :
The error is the same if I use public or protected. I have tried declaring a a private variable in...
|
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...
| |
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |