Hello,
I'm trying to split my main.cpp into several.cpp files. I'm using a single header file to contain all my definitions.
I am using multiple structs to organize my variables. this was working nicely in the original main.cpp. But when I moved the struck definitions to the new header file (in order to be used in multiple .cpp files) and declare a struct object in the main.cpp. this error (0xc00000fd) happens.
I have noticed that if I include a small part of the struct the problem doesn't happen. but of course, I need to include all of them. how to solve this problem.
yes, I think it's a large array( multiple arrays), but it was working without any problem in the original single main.cpp file. Once I moved the declaration of the structs to the header.h, I start getting the error.
why didn't I run out of stack memory in the first situation, but I did in the second one?
is it a wrong way to use structs with a header file?
is it a wrong way to use structs with a header file?
No, it is not wrong. It's pretty much required if you need these struct types in multiple source files.
There's no way this "was working without any problem in the original single main.cpp". It makes absolutely no difference whatsoever. Try putting it all back in main.cpp and it will have the same problem.
You should rethink your problem to determine if you really need all of that complexity, but if you really do need it all you can make it work by simply putting the keyword "static" in front of all the variable definitions that use these structs in main.