Thread: How do you name such project folders?

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    18

    How do you name such project folders?

    Hi have 2 types of include folders:

    First folder contains any sources that can be used for another projects

    Second folder contains any sources for the specific project.

    Currently this is my folder structure and is the best I could think of

    Code:
    Resources
    Sources
        Include (First folder)
        Program (Program source code)
               Include (Second folder)
               Program.cpp
               Program.h
    Believe me or not, it is very hard question for me

    Thank you
    Last edited by gil900; 04-18-2019 at 01:20 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    For all my own work, it goes something like
    Code:
    ~/code
      MyFooLib
        .git           // The SCM of choice
        include        // The public interface
        lib            // The compiled lib to link against
        src            // The source, may have a nested directory structure
      MyBarLib
        .git           // The SCM of choice
        include        // The public interface
        lib            // The compiled lib to link against
        src            // The source, may have a nested directory structure
      Project1
        .git           // The SCM of choice
        bin            // The compiled executable programs
        obj            // The compiled object files
        src            // The source, may have a nested directory structure
      Project2
        .git           // The SCM of choice
        bin            // The compiled executable programs
        obj            // The compiled object files
        src            // The source, may have a nested directory structure
    Includes and libs come from 3 places.
    - The standard libraries, and whatever comes pre-packaged with the OS, which are typically in /include and /lib

    - Third party packages you download, compile and install yourself, which usually end up in /local/include and /local/lib (or perhaps /opt)
    filesystem - Use of /opt and /usr/local directories in the context of a PC - Ask Ubuntu

    - Libraries you create yourself can be organised however you want. But adopting some common system "as if" you were going to release it to the world saves you from having to re-invent the wheel, or undertaking needless restructuring should you decide to actually release your library.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2019
    Posts
    18
    Thank you. It helped me.
    I think it took me a week to think about my own standard of structure.

    See:

    Code:
    Include     // Shared libraries - Libraries that used for other projects and not stored in any project
        MyFooLib
        MyBarLib
        ...
    
    
    ProjectA // Some project
        Resource // Resource for the project
            icon.png
            manifest.json
            ...
        Source // Source code of the project
            Include // Libraries that can be hosted as shared libraries but for now they are here
                MyBazLib
                MyQuxLib
                ...
            Modules // Collection of modules that used for the source (Sources files that are specific for the program)
                Main.h // The main entry that manage all the logic that implemented in ModuleA, ModuleB and more
                Main.src.h /* Source code of the main entry.
                                This file contains 2 functions:
                                    bool Init() - This function will call to initializer methods of ModuleA, ModuleB (if needed)
                                     int While() - This function should be called after all inits
                                                    The function will call to any processing function under ModuleA, ModuleB if needed
                           */
                ModuleA.h // Contains any declarations (variables, functions, classes) for ModuleA 
                ModuleA.src.h // Contains any definitions for ModuleA 
                ModuleB.h    // Same ...
                ModuleB.src.h // Same ..
                ...
            Boot.cpp /* The "boot loader" is the only cpp file with the main() method.
                        It responsible for performing the *boot operation* of the Program.
                        *boot operation* = any logics that are *initializations*.
                        *initializations* = the following tasks:
                            - Include any Shared libraries (example: MyFooLib, MyBarLib)
                            - Include any other libraries under include folder in Source folder
                            - Include all Modules. *First include the .h files and then include the .src.h files
                            - May declare variables and functions that are used for the *boot operation* logic.
                                (for example, it may do some logic that is a result of command line parameters)
                            - The main() function will be here and:
                                A) Call to Main::Init()
                                B) Following code:
                                    int exitCode = Main::While();
                                    return exitCode;
                        */
    I think that this is the best way to do it according to a lot of my thoughts experiments and other experience from different programming languages.
    What do you think?
    Last edited by gil900; 04-18-2019 at 03:57 PM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Code:
    Include     // Shared libraries - Libraries that used for other projects and not stored in any project
        MyFooLib
        MyBarLib
    If Foo and Bar are not mutually dependent, then having them both under a common include directory may be an issue.

    Sure, your ProjectA make rules have one less -I parameter.

    But what if ProjectB only needs MyFooLib?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Apr 2019
    Posts
    18
    Why it may be an issue?

    Then ProjectB will not include MyBarLib

    I created to myself this page:
    GitHub - gileli121/CPP-Project-Structure: My standard of how to structure C++ code

    It explains the rules better

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 08-02-2013, 06:45 PM
  2. Help with folders
    By FlyingIsFun1217 in forum C++ Programming
    Replies: 5
    Last Post: 10-21-2006, 09:41 AM
  3. folders
    By adrumsolo4u in forum C++ Programming
    Replies: 2
    Last Post: 03-31-2005, 01:04 PM
  4. Deleting folders and sub folders
    By Boomba in forum C++ Programming
    Replies: 30
    Last Post: 06-11-2003, 11:58 AM
  5. Folders
    By Driveway in forum C++ Programming
    Replies: 1
    Last Post: 06-24-2002, 09:35 AM

Tags for this Thread