in reply to Re^4: porting C code to Perl
in thread porting C code to Perl
So you're saying that this code:
#include <stdio.h> int value; void main(void) { printf("%d\n", value); }
may output something else then 0 on these platforms/compilers? Looking at ANSI C (as the smallest common base) I would say these compilers are in violation of the C Standard and cannot be truly called C. (But I may be wrong - I'm not a greybearded C guru.)
From the C89 standard, section 3.5.7
If an object that has static storage duration is not initialized explicitly, it is initialized implicitly as if every member that has arithmetic type were assigned 0 and every member that has pointer type were assigned a null pointer constant.(I am deliberately quoting C89 and not a more recent standard too make sure this isn't a later addition / clarification.)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: porting C code to Perl [OT]
by haukex (Archbishop) on Oct 25, 2017 at 10:14 UTC |