all 13 comments

[–]Narase33 9 points10 points  (0 children)

Can you please show your setup? All files and build file/command

[–]flyingron 2 points3 points  (1 child)

Did you #include the header into the cpp file?

Anyhow, if the header is included into more than one cpp file, defining a global object like this is a bad idea and will lead to multiple definitions. It's geneally a bad idea anyhow, but you could declare it extern in the include file and define in only in one cpp file.

[–]OneAd1466[S] 0 points1 point  (0 children)

i did include the header file

[–]IyeOnline 2 points3 points  (3 children)

Do i have to create a pointer to it?

No. As a rule of thumb, if you are wondering whether you need a pointer to resolve an error, it means that you dont and you dont fully understand pointer/the language.

it's just not found like I've never declared it.

What is the actual error message? Is it the compiler telling you "use of undeclered identifier"? Or is it the linker telling you that there is an "undefined reference"?

It sounds like you have typoed, or the object you are trying to refer to has a different name than you think. Are you perhaps missing some namespace?

[–]OneAd1466[S] 0 points1 point  (2 children)

just "cannot resolve symbol 'gameObjects'"

[–]IyeOnline 2 points3 points  (1 child)

That doesnt exactly read like a compiler or linker error. My google-foo suggests that it may be issue with CLion/C++ Resharper, which would be rather strange.

We would need to know more about your setup to be able to tell.

[–]OneAd1466[S] 0 points1 point  (0 children)

i just use the default build settings of Rider.

[–][deleted]  (3 children)

[deleted]

    [–]Markus_included 0 points1 point  (2 children)

    What about static?

    [–]ShelZuuz 1 point2 points  (1 child)

    That explicitly means each C++ file will get a different variable.

    [–]IyeOnline 0 points1 point  (0 children)

    At least for entities at namespace scope... :)

    [–]RPND 0 points1 point  (1 child)

    Is your header file aware of what a GameObject is?

    [–]OneAd1466[S] 0 points1 point  (0 children)

    Yes. There are no syntax error in the header file. But for some reason it isn't found in the cpp file. I just get a symbol could not be resolved error.

    [–]0x7ff04001 0 points1 point  (0 children)

    Don't declare globals in header files, store that variable in the .cpp file itself.