I'm not sure if i'm asking a valid question, but here goes.
I have c++ solution with a structure of
[folder] Header files -
... 200 header files ..
[folder] Source files -
... 200 soure files ..
... rest
Is it possible to organize header and soure files by folders as you would in a C# project? The problem I'm facing is, as the project grows, it gets tiresome to navigate through a huge pile of files, which would be much easier to navigate to, if they were organized by functionality (such as folders and namespaces in c# projects).
Is there a some kind of standard, that would be supported by a wide variety of compilers and not Visual Studio alone ?
Example:
[folder] Header files -
[folder] Source files -
... rest
If you are including a C header file that isn't provided by the system, you may need to wrap the #include line in an extern "C" { /*... */ } construct. This tells the C++ compiler that the functions declared in the header file are C functions.
The headers will never get compiled, unless included in a cpp file first. Typically headers are declarations and cpp are implementation files. In the headers you define an interface for a class or function but you leave out how you actually implement the details.
The short answer is that a . h file contains shared declarations, a . cpp file contains definitions and local declarations. It's important that you understand the difference between declarations and definitions.
Yes, you can create your own header file. Kindly go through thinking in c++ by bruce eckel vol 1. These files have declaration of user defined data structures and interfaces such has class declaration, function prototypes and etc.
Header/Source file is not a requirement imposed by Visual Studio. That's just the default layout, and it's virtual, not physical. If you click "Show all files" in the solution explorer, it will show the folder tree as it is on the hard drive- which you can manipulate as you see fit. This is the only sane configuration and I have no idea why the default is that way. Plus, naturally, they fixed it for C# projects but not C++.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With