User Profile

Collapse

Profile Sidebar

Collapse
vivekbhadra
vivekbhadra
Last Activity: Jun 25 '09, 03:00 PM
Joined: Jun 25 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • vivekbhadra
    replied to Global variable and static global variable
    in C
    =============== =============== =============== ==========
    >>If a translation unit contains one or more tentative
    definitions for an identifier, and the translation unit contains no
    external definition for that identifier, then the behavior is exactly
    as if the translation unit contains a file scope declaration of that
    identifier

    .... the above line from your post explains my point. a "tentative...
    See more | Go to post

    Leave a comment:


  • vivekbhadra
    replied to Global variable and static global variable
    in C
    [QUOTE=JosAH;349 6091]

    =============== =============== =============== =========
    >>anywhere (not just in a header file) it's a definition and it's tentative.

    nothing is tentative in the C paradigm unless you have created your own . there is absolutely no confusion about the fact that unless a header file is included in a C file a declaration never gets into a definition as it doesn't still have a memory allocated....
    See more | Go to post

    Leave a comment:


  • vivekbhadra
    replied to Global variable and static global variable
    in C
    [QUOTE=JosAH;349 6086]
    =============== =============== =============== ========
    >>There's no need to explain the semantics of the word 'static' to me; I know what it is.

    so as I do ..... and just one more information when you are talking about a header file it's always declaration not definition .... until the header file is included in a C/C++ file it never gets it's memory allocated ... so it's a declaration in a...
    See more | Go to post

    Leave a comment:


  • vivekbhadra
    replied to Global variable and static global variable
    in C
    =============== =============== =============== ==============
    and you don't want multiple copies of your static variable... right ? why does one in the first place declare a variable as a static variable in a header file ? one can only do that assuming this would be unique across the compilation units and so ( by mistake of course). but otherwise there can be no sesible reason on wants to declare something as static in a header file. that's...
    See more | Go to post

    Leave a comment:


  • vivekbhadra
    replied to Global variable and static global variable
    in C
    =============== =============== =============== ============

    a static variable defined in the global space in a file cannot be accessed from other files because it doesn't have an external linkage. the example I have given exactly says that. look below for once again:

    /*Illegal use of static variable*/
    /*File: test1.c*/
    #include<stdio. h>
    #include "header.h"
    int i = 100;
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...