CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Threading in c

  1. #1
    Join Date
    May 2010
    Posts
    25

    Threading in c

    Hi,
    I'm trying to create some threads in c and I got an example code.
    It says I have to include the file thread.h, however the compiler says it cannot find the file.
    How can I solve this?

    Thanks.

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Threading in c

    Which threading library are you using? C doesn't have a standard threading library, but pthreads is a commonly-used one. The only one I can find offhand which has a "thread.h" is Solaris threads, which is similar but less commonly supported.

    C++ does define standard threads in the newest standard, but I don't think any compilers actually support that yet.

  3. #3
    Join Date
    May 2010
    Posts
    25

    Re: Threading in c

    Is there a windows-based library that I can use?

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Threading in c

    Yes, but in my opinion it offers few advantages over the cross-platform options.

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

    Re: Threading in c

    What kind of library is needed? Native calls like CreateThread and _beginthreadex let you deal with threads without dependency on any library. In Windows, of course.
    Last edited by Igor Vartanov; June 4th, 2010 at 12:22 PM.
    Best regards,
    Igor

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

    Re: Threading in c

    Quote Originally Posted by dragonuv View Post
    Is there a windows-based library that I can use?
    _beginthread, _beginthreadex
    _endthread, _endthreadex
    Victor Nijegorodov

  7. #7
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Threading in c

    Quote Originally Posted by Igor Vartanov View Post
    What kind of library is needed? Native calls like CreateThread and _beginthreadex let you deal with threads without dependency on any library. In Windows, of course.
    Just to be pedantic, I'd say that the Windows Platform SDK qualifies as a library.

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

    Re: Threading in c

    To be pedantic the same way, I cannot fully agree with this. Development Kit is not equal to Library. In some aspects it's more than a library been rather a bunch of specific libraries. But in others it's less.
    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