News for hackers. Stuff that matters.
Re:Fuchsia is not Linux by pjmlp on Thursday April 12, 2018 @05:16AM (#16819197)
Yes, but global variables are not necessarily static.
Re:Fuchsia is not Linux by bb88 on Thursday April 12, 2018 @05:35AM (#16819267)
I think you're missing the point entirely here.

C++ has to run code before main if a ctor is in a class that's static. There's no other way to initialize that static object.

C prevents this by requiring static storage to be initialized with constants.

Re:Fuchsia is not Linux by pjmlp on Thursday April 12, 2018 @06:43AM (#16819510)
Fair enough.
Re:Fuchsia is not Linux by caf on Thursday April 12, 2018 @07:00AM (#16819574)
All variables declared at file scope have static storage duration in C.
Re:Fuchsia is not Linux by pjmlp on Thursday April 12, 2018 @07:39AM (#16819795)
I was talking about using static keyword.
Re:Fuchsia is not Linux by caf on Thursday April 12, 2018 @07:45AM (#16819828)
Yes, but what's important here is the storage duration, which the static keyword doesn't affect at file scope (it just affects the symbol scope).
Re:Fuchsia is not Linux by jmaygarden on Thursday April 12, 2018 @09:02AM (#16820433)
Use of static in the context of that C snippet is deprecated in C++. One is supposed to use an unnamed namespace instead.

    namespace {
        int myfunc() {
            return 5;
        }
    
        int x;
        int y = 4;
        int z = myfunc();
     };

     int main()
     {}
In my opinion, his point is still valid.
Re:Fuchsia is not Linux by j4_james on Thursday April 12, 2018 @06:20PM (#16825452)
Just FYI, I believe that deprecated usage was later undeprecated. See https://stackoverflow.com/questions/4726570/deprecation-of-t...