简体   繁体   中英

Exporting an inline struct in c++

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM