File and Folder structure of a App/Project based i

2019-02-03 14:11发布

问题:

What would be the general structure of a App/Project based in C Programming language. libs, includes, header files. etc etc.

What would be the class structure. (in OOps) need to be scalable and other features. Something like main.cpp main.h

does any one have any good links or images or pdf?

回答1:

Most of the projects follow a single hierarchy as follows:

project
\_ conf\   --> configuration files (Unix/Linux projects might prefer an 'etc' folder)
\_ src\    --> main source (for C++ projects, headers and sources go along, but if 
              your project is a library then separating include files for others 
              is a better practice)
\_ src\module1\ --> for each sub module (for multiple files having related contents,
                   it is better to separate them to their own subfolders)
\_ doc\    --> documentation 
\_ include\ --> (for library projects, the distributable include files)
\_ os\     --> OS (platform dependent) files (uch as makefiles, package building
              scripts..)
\_ res\    --> resources required for compilation but not source files (icons, etc.)
\_ MAKEFILE --> makefile script for building the project
\_ README   --> introductory document (might refer to doc\README)
\_ INSTALL  --> Installation document (might refer to doc\INSTALL)


回答2:

For the directory layout/class structure I suggest reading this

http://www.javapractices.com/topic/TopicAction.do?Id=205

The link talks about Java but it applies to any Language (even non- OOP)

You might also find this interesting

http://www.gnu.org/prep/standards/html_node/index.html



回答3:

What you could do is find an open-source project in the same domain and study their project structure and adapt it as needed.



回答4:

I guess there are no common guidelines (at least, i've heard of none). Every company seem to have its own practices and recommendations. You may only rely on yourself and do whatever suits your current needs, i think.

Here's a link to the Google C++ Style Guide, if you haven't seen it already: https://google.github.io/styleguide/cppguide.html (they've got lots of ideas there, but i don't accept some of them, so it is a matter of choice)

Here's some other random guideline: http://geosoft.no/development/cppstyle.html

I guess you may take a look at those, but there is no general rule of thumb. Everything depends on your exact task.



回答5:

Create individual libraries according to the functionality,make single include for all header files If it is C use .h or If it is C++ use .hpp format .then have single main file followed make to build all the libraries

OOPS will follows Main.cpp &Main.hpp format