How Do You Organize Your C++ Project File Structure? - /g/ (#105992250) [Archived: 322 hours ago]

Anonymous
7/22/2025, 11:24:22 PM No.105992250
file_structure
file_structure
md5: 9ccae1f6fbea6f9a04267b5c131f0afd🔍
Are you a /src/ and /include/ guy? Where do you put other libs that are projects of their own and other cross-platform versions of your app?
Replies: >>105992654 >>105993186 >>105994870 >>105995396 >>105995451
Anonymous
7/22/2025, 11:58:06 PM No.105992654
>>105992250 (OP)
All in the same directory. If you need a more complex file structure it means you're using too many files.
>Where do you put other libs that are projects of their own
Same directory. Most of them are single files.
>other cross-platform versions of your app?
Why would I make versions for other platforms?
Replies: >>105992674
Anonymous
7/23/2025, 12:01:09 AM No.105992674
>>105992654
> If you need a more complex file structure it means you're using too many files.
Did you ever work on real software?
Replies: >>105992745
Anonymous
7/23/2025, 12:03:08 AM No.105992696
main.cpp is all you need
Replies: >>105994949
Anonymous
7/23/2025, 12:08:33 AM No.105992745
>>105992674
Mostly command line porn stuff for my personal use but I consider it real software.
Anonymous
7/23/2025, 12:56:40 AM No.105993186
>>105992250 (OP)
if you think cutting up your code into tiny pieces where each struct goes into a single file will make your code more readable than you are better off going back to java with the jeets
Anonymous
7/23/2025, 4:43:32 AM No.105994870
>>105992250 (OP)
Not a C++ dev but last software I vibe coded was a security tool for an online game that reencrypts the traffic to block boting, so it had to be on C++. I just placed everything on a single cpp file and used large comment lines to organize the file sections. It looks kinda cool on vscode.
Replies: >>105994943 >>105995206
Anonymous
7/23/2025, 4:56:13 AM No.105994943
>>105994870
The horror.
Replies: >>105995556
Anonymous
7/23/2025, 4:56:43 AM No.105994949
>>105992696
I've inherited two projects at work that are just this.
Anonymous
7/23/2025, 5:36:26 AM No.105995206
>>105994870
Post screenshots
Replies: >>105995556
Anonymous
7/23/2025, 6:08:21 AM No.105995396
>>105992250 (OP)
C++ modules don't have this problem.
Anonymous
7/23/2025, 6:18:57 AM No.105995451
>>105992250 (OP)
I used to do /src & /include but have since stopped, everything goes in the root now (except public headers) with main and module glue files being at the true root and the code for modules being in sub directories. I have a /lib folder where I place all my stolen code and git submodules. My build folder has a directory for each target I support, used to just clean and switch targets but I found when developing I would test on each target and clean building each time was stupid
Anonymous
7/23/2025, 6:24:33 AM No.105995484
main.cc goes in root. all my stuff in src. everything else it its own directory.
Anonymous
7/23/2025, 6:36:53 AM No.105995556
1000044383
1000044383
md5: 9489fa2bc9f77078b214f51564ffc239🔍
>>105995206
I'm on my phone, don't really know any better way to share this.
>>105994943
LOL for my own surprise, it actually works
Replies: >>105995583
Anonymous
7/23/2025, 6:42:15 AM No.105995583
>>105995556
reinterpret_cast is a code smell. use bit_cast