CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jul 2013
    Posts
    161

    multiple projects

    going through an application which has multiple projects in it, that is looking in it source code through visual studio...

    All the projects have their main.cpp or core.cpp file and they all do have their void WINAPI _entrypoint()
    or simply void WINAPI entrypoint() functions

    1)my question is how do multiple projects communicates and when and how is control passed from one to the another?

    how does the windows OS know that is has to start from this particular WINAPI entrypoint()?


    actually I'm trying to lay the track of the app, to find it starting point and walk through it to the end...

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: multiple projects

    I'm not sure I fully understand to what you are referring. The names of files are irrelevant to their purpose. A solution consists of one or more projects with each project consisting of one of more source files.

    For each non-mfc project, these are either an .exe or a .dll. For a .dll, only one source file may have DllMain() entry point - but this is not required. For an .exe, there are two entry points that may be defined. For a console application this is main(). For a windows program this is WinMain(). A project may contain both main() and WinMain() entry points. Which one is used is determined by the project options. But within a project there can only be one of each and must contain the one for the type of project.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: multiple projects

    Quote Originally Posted by TheLionKing View Post
    going through an application which has multiple projects in it, that is looking in it source code through visual studio...
    What do you mean by "an application which has multiple projects in it"?
    Perhaps, you mean "solution which has multiple projects in it"? Or not?
    Victor Nijegorodov

  4. #4
    Join Date
    Jul 2013
    Posts
    161

    Re: multiple projects

    I meant that Master VictorN, a solution which has multiple projects in it..yes...does it make it my question clearer? can something more be added to what Master 2kaud said?
    to confirm was 2kaud said, yes in each project there is one WINAPI entrypoint()...I know for sure that the individual projects makes up one application in the end, they are all part of the same solution...
    so at least, one "SUPER" main entry point is at least needed right? is there no way to specify or know that?
    Last edited by TheLionKing; July 12th, 2016 at 08:33 AM.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: multiple projects

    Victor Nijegorodov

  6. #6
    Join Date
    Jul 2013
    Posts
    161

    Re: multiple projects

    that was helpful, thanks

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: multiple projects

    so at least, one "SUPER" main entry point is at least needed right? is there no way to specify or know that?
    I'm not sure what you mean by 'Super' main entry point. The functions main(), WinMain(), DllMain() are 'hard wired' and fixed into the system and can't be changed. They need to be used as stipulated.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  8. #8
    Join Date
    Jul 2013
    Posts
    161

    Re: multiple projects

    I'm not sure what you mean by 'Super' main entry point. The functions main(), WinMain(), DllMain() are 'hard wired' and fixed into the system and can't be changed. They need to be used as stipulated
    What I meant was that, the whole application at the end of the day must start from somewhere...since there are many projects with their starting points, where does the whole app start from or which project start the whole application rolling...but I just learnt reading that it seems that can be specified explicitely in configurations...

  9. #9
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: multiple projects

    Quote Originally Posted by TheLionKing View Post
    What I meant was that, the whole application at the end of the day must start from somewhere...since there are many projects with their starting points, where does the whole app start from or which project start the whole application rolling...but I just learnt reading that it seems that can be specified explicitely in configurations...
    A solution is just a collection of projects - nothing more nothing less. Just because a solution has a set of projects in it, doesn't mean they interact with each other at runtime.

  10. #10
    Join Date
    Jul 2013
    Posts
    161

    Re: multiple projects

    that is very right too Arjay....

  11. #11
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: multiple projects

    A reason for bundling a number of projects into a single solution might be the EXEs are to depend on the same bunch of static/dynamic libraries, so all those would be built in a single whiff, and maybe a test suite(s) to be run as well to test the core functionality as much as possible.
    Best regards,
    Igor

  12. #12
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: multiple projects

    Quote Originally Posted by TheLionKing View Post
    how does the windows OS know that is has to start from this particular WINAPI entrypoint()?
    The entrypoint is placed into EXE's PE header by linker, so Windows always knows for sure where to start from.

    Linker Option: /ENTRY (Entry-Point Symbol)

    Typically, entrypoint is unambiguously stipulated by project type. However, sometimes it has to be specified explicitly to circumvent some CRT features. And sometimes it is deliberately specified for some reason having nothing common with conventional programming culture. Like showing how cool I am and what sort of weird stunts I've learnt.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured