C++ Logo

std-discussion

Advanced search

Re: Global array of objects over multiple files

From: Federico Kircheis <federico_at_[hidden]>
Date: Tue, 22 Oct 2024 14:39:39 +0200
On 22/10/2024 12.09, Lauri Vasama via Std-Discussion wrote:
> I just want to be clear; are you aware that const implies static on
> global variables? Because you declare the global variable "instance"
> const, and have placed it in a header, each translation unit that
> includes the header gets its own local copy of the "instance" variable
> with internal linkage.

In case you are asking me: Yes I am.
Why the question?

And sorry to Thiago.
You wrote ill-formed and I continued to write UB, but my example is not
ill-formed either (unless you remove const).

Received on 2024-10-22 12:39:47