Struct "XXXX does not name a type"

I have read many answers to this problem but I have something basically wrong I do not understand.
I created a bare sketch to help understand it simply. Setup and Loop are empty to highlight the error.

This codes gives the error " 'my_point2' does not name a type " at the line "my_point2.x = 4;"
Thanks.

struct point{
    int x;
    int y;
    float z;
};
 
struct point my_point1;
 
struct point my_point2 = {2, 5, 3.7};
 
my_point2.x = 4;  //error here


void setup() {

}

void loop() {

}

This line needs to be inside a function

my_point2.x = 4;  //error here

Arduino uses C++, not C. You don't have to keep saying "struct" each time you use your struct.

You cannot have normal statements at the global scope (outside of functions). The compiler expects a declaration, so the first word should be a type.

struct point {
    int x;
    int y;
    float z;
};
 
point my_point1; // Declaration
 
point my_point2 = {2, 5, 3.7}; // Declaration and aggregate initialization
 
void setup() {
  my_point2.x = 4; // Assignment statement
}

void loop() {}

Pieter

That was it. Must have assignment statements inside a function such as Setup(), Loop(), or other Function.

Thank you.