![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
No thread.h file?
I was just about to start getting into threading, but when I try to, the compiler doesn't recognize things like THREADID and thread_create. So I figured I had to include a thread header file, but I don't have one that is related to threads. Should I have a thread.h file (or similar), or should my compiler be recognizing the thread things without it?
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
Neither.
Anything to do with threading (eg creating threads, executing functions in them, synchronisation between threads) is firmly outside the scope of standard C or C++. Both the C and C++ standards implicitly assume there is only one thread of execution in a program, which means there is no need for any support of multi-threading. There is some discussion in progress about changing that in a future version of those standards. thread_create() is a POSIX function (i.e. it is described in one of the POSIX [Portable Operating System Interface] family of standards). There is no requirement that a C or C++ compiler will recognise POSIX functions, no requirement that there will be a thread related header file, and no requirement that the library bundled with a compiler will include implementations of POSIX functions. If you want to use threads, you will need to read the documentation that comes with your compiler and its library. If you're lucky, they will support POSIX functions. If they don't support POSIX functions, they might support some other set of functions that can be used to implement threaded applications. If there is no threading support at all (which is the case for compilers targeting old systems, as threading typically relies on some form of support from an operating system) then you are probably out of luck. |
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2
![]() |
|
|
|
|
|
|
#4 |
|
Unverified User
Join Date: Jul 2007
Location: England
Posts: 22
Rep Power: 0
![]() |
If you are on windows there are also the Win32 thread functions, CreateThread, TherminateThread etc. If you use Win32 threads it will not be easy to port your code to a non Win32 platform, so if portability is important or you are not using windows then POSIX threads are the way to go. On MSDN there is plenty of documentation on how to use Win32 threads properly. windows.h includes the prototypes for the Win32 thread functions.
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
pthreads sounds like what I want to use, but I don't have pthreads.h either... Can I get that somewhere?
|
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Writ, you got tons of good responses. Did you bother to Google "pthreads"?? I did, so I'm going to have to guess, "No". Part of being a decent programmer is learning to change your own underwear.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
Woah, hold on there. Yes, I did google pthreads, DaWei. Well, more specifically, I googled "pthreads download" (without the quotes). The links that looked promising didn't get me what I was looking for. I found one that I think would have worked, but it was a tar.gz, and to be honest I've never understood what I'm supposed to have to access those types of files. So, after a few dead-ends, I figured I'd just ask if someone knew of a link, since I already had the thread started--I wasn't trying to get people to look for me. I know I ask a lot of questions on here, but I always google first.
|
|
|
|
|
|
#8 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
I found a link with the file available. Thanks a ton for the link to the tutorial, it looks like it will be great to start out with.
|
|
|
|
|
|
#9 | |
|
Call me Chuck
|
Quote:
|
|
|
|
|
|
|
#10 |
|
Professional Programmer
|
He stated he found a link. There's no need to dredge up week old threads to offer a solution to a problem he's already solved.
__________________
Amateurs built the ark Professionals built the Titanic |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem processing file into a char array | csrocker101 | C++ | 1 | May 8th, 2007 11:50 PM |
| OnlineTextEditor.Com! | Sane | Show Off Your Open Source Projects | 43 | Jun 16th, 2006 8:55 AM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |
| Structure char field to a disk file | ehab_aziz2001 | C++ | 0 | Feb 10th, 2005 2:42 PM |