Hello ragezone,
so I technically know how headers work, you put the "layout" in the header and then the implementation in the complementary .cpp file. But still the more my client project grows, the more trouble I seem to have with #include and whatnot.
Currently when I add a new class, there will be like a 50% chance that my project will not compile anymore. The compiler will then keep giving me misleading errors like: "missing type specifier" (but the type specifier in question is a class that I added last week and that worked fine before).
Those errors can take me up to an hour to debug and the solution is usually to swap the positions of two header's #include or similiar nonsense.
Here are the errors I usually get (none of which make any sense if I look at the code):
- Missing type specifier
- Missing ";" before "packet_creator" (where packet_creator is a variable name)
- Type X was not defined in this scope (it was)
Visual Studio by default adds "#pragma once" in each header file, which supposedly fixes #include collisions. But apparently I still manage to ruin my project every time.
I know that this question is very general, but googling it didn't really give me anything. Questions about it on stackoverflow are usually by people who actually do have these errors in their code.
Any tips for this? How do the c++ users here organize their code to avoid these problems? Help is appreciated, thanks.
so I technically know how headers work, you put the "layout" in the header and then the implementation in the complementary .cpp file. But still the more my client project grows, the more trouble I seem to have with #include and whatnot.
Currently when I add a new class, there will be like a 50% chance that my project will not compile anymore. The compiler will then keep giving me misleading errors like: "missing type specifier" (but the type specifier in question is a class that I added last week and that worked fine before).
Those errors can take me up to an hour to debug and the solution is usually to swap the positions of two header's #include or similiar nonsense.
Here are the errors I usually get (none of which make any sense if I look at the code):
- Missing type specifier
- Missing ";" before "packet_creator" (where packet_creator is a variable name)
- Type X was not defined in this scope (it was)
Visual Studio by default adds "#pragma once" in each header file, which supposedly fixes #include collisions. But apparently I still manage to ruin my project every time.
I know that this question is very general, but googling it didn't really give me anything. Questions about it on stackoverflow are usually by people who actually do have these errors in their code.
Any tips for this? How do the c++ users here organize their code to avoid these problems? Help is appreciated, thanks.