Why I can't include <pthread.h> in .NET

This is a discussion on Why I can't include <pthread.h> in .NET within the C++ Programming forums, part of the General Programming Boards category; I am programming multi-thread codes in .NET I tried to #include <pthread.h> But complier reproted Cannot open include file: 'pthread.h': ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    Why I can't include <pthread.h> in .NET

    I am programming multi-thread codes in .NET
    I tried to #include <pthread.h>

    But complier reproted
    Cannot open include file: 'pthread.h': No such file or directory.

    What happened? How can I implement multi-thread in .NET?

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Are you sure that the include directory has the header file in question?

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    It probably doesn't. pthread.h is the main include of the POSIX thread library, which doesn't exist by default on Windows.

    You have three options.

    1) Use the threading functions of the Win32 API: CreateThread (_beginthreadex if you're using the CRT or C++, i.e. always) is a good starting point.
    2) Use a pthread library implemented on top of the Win32 API. There are one or two good ones out there.
    3) Use an entirely different, cross-platform threading library. Boost.Thread is the most obvious choice, and generally a very good choice in C++ because of its good support for C++ idioms. In addition, toolkits like Qt and wxWidgets have threading libraries.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    284
    Thank you, CornedBee.
    For the option (1), what class should i use. Cthread?

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Huh? What class? The Win32 API has no classes.

    Are you using MFC? The .Net framework?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    284
    Quote Originally Posted by CornedBee View Post
    Huh? What class? The Win32 API has no classes.

    Are you using MFC? The .Net framework?
    No, CornedBee. I am just using VS 2005. Which header should I include to support multi-threaded programming?

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    windows.h
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 04:45 AM
  2. 2d game
    By JordanCason in forum Game Programming
    Replies: 5
    Last Post: 12-08-2007, 10:08 PM
  3. Weird, cards not outputting correctly
    By Shamino in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2007, 03:26 PM
  4. does not name a type ERROR
    By DarrenY in forum C++ Programming
    Replies: 3
    Last Post: 10-13-2007, 05:54 AM
  5. dont konw what to do next.
    By negevy in forum C Programming
    Replies: 29
    Last Post: 09-09-2005, 04:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21