Reputation: 184
I was programming in c++ and I came across an issue. I had a struct for the player in a header file and wanted to use the struct in two different files.
struct {
float x;
float y;
} player;
I tried many things and I did much research but it always resulted in errors or the variables not updating throughout all the files. However I made a discovery, you can use
inline struct EXPORT {
float x;
float y;
} player;
(c++17) Ive looked online and I cant find anyone talking about this, ive even searched "inline struct EXPORT" on github and no code results came up. I wonder if ive made a discovery. I am wondering if this is a known syntax and if it is a good idea to use such a function.
Upvotes: 0
Views: 357
Reputation: 238351
am wondering if this is a known syntax
Yes. The syntax of variable and class definition is known. In this case, you define an inline variable named player
which is of a class type named EXPORT
.
There is no "exporting" involved here.
Upvotes: 1