=============== =============== =============== ==========
>>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...
User Profile
Collapse
-
[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....Leave a comment:
-
[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...Leave a comment:
-
=============== =============== =============== ==============
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...Leave a comment:
-
=============== =============== =============== ============
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;
...Leave a comment:
No activity results to display
Show More
Leave a comment: