CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2010
    Posts
    54

    How to know if a VS2008 project supports multithread or not?

    Hi,

    I get a VC2008 project with full source. How to know whether it supports multithread or not? I think as long as the “Runtime Library” under “C/C++” - “Code generation” category is set to “Multi-threaded”, then the project should be thread-safe, is that correct? Or are there any other project settings need to be checked?

    Thanks

    Alan

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to know if a VS2008 project supports multithread or not?

    “Multi-threaded” category does NOT mean that "the project should be thread-safe", but only it "supports multithread".
    It is up to project developer to do a project to be "thread-safe" or not.
    Victor Nijegorodov

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

    Re: How to know if a VS2008 project supports multithread or not?

    Quote Originally Posted by AlanCCC View Post
    I think as long as the “Runtime Library” under “C/C++” - “Code generation” category is set to “Multi-threaded”, then the project should be thread-safe, is that correct? Or are there any other project settings need to be checked?
    This runtime setting is exactly what it says: C Runtime multithreading.

    And there is no setting that would turn on or off multithreading for entire project, as any Windows process natively supports multithreading. You can create a multithreaded program even when linking to single threaded runtime, you just have to be careful enough to not use runtime objects across threads bounds.

    And to the point of being thread safe, I agree with Victor, it's strictly up to programmer to make it be that, as C/C++ knows nothing about threads.
    Best regards,
    Igor

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

    Re: How to know if a VS2008 project supports multithread or not?

    Certain functions (eg _beginthreadex) are only declared in the header file if the code generation is set to 'Multi-threaded'.
    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)

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How to know if a VS2008 project supports multithread or not?

    popping a few myth bubbles here...

    _EVERY_ program you write for windows inherently supports multithreading. All it takes is create the extra threads either through the windows API functions, the runtime lib or some other library that allows you to do so.

    Even if you don't make any extra threads in your own code. The OS dll's itself, drivers, hooks etc can all create additional threads.

    So your answer is sort of a bogus one, it is literally impossible (other than hacking deep into the OS kernel) to create an application on windows that will guarantee that at no time during it's runtime no additional threads can ever be created.


    Even if you compile your program as non-MT. You can still create threads and do so safely, one restriction is going to be that the thread cannot use (some of) the runtime library functions.
    Regardless, you're always subject to whatever libs you are using and to what degree those libraries support being called from multiple threads at the same time.

    Most of the windows API is fully MT enabled (part of it isn't), but that doesn't mean you can safely access a single resource simultaneously.

    Any time you access a single resource/memory/object/handle/something from 2 threads at the same time, you're Always going to need to ask the question if doing so is thread safe.

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

    Re: How to know if a VS2008 project supports multithread or not?

    Quote Originally Posted by OReubens View Post
    So your answer is sort of a bogus one.
    Which answer is bogus?

  7. #7
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How to know if a VS2008 project supports multithread or not?

    Typo: I meant a bogus/meaningless QUESTION.

Tags for this Thread

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