Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6748099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:31:30+00:00 2026-05-26T12:31:30+00:00

I saw this question Simple example of threading in C++ but my problem is

  • 0

I saw this question Simple example of threading in C++
but my problem is that I want to run this program in windows 32 and it seems that pthread is not recognized in windows!please tell me what is problem?This is my error:
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include “StdAfx.h”‘ to your source?(I added #include “StdAfx.h but it still
does not work!)

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define NUM_THREADS 5

void *PrintHello(void *threadid)
{
  long tid;
  tid = (long)threadid;
  printf("Hello World! It's me, thread #%ld!\n", tid);
  pthread_exit(NULL);
}

int main(int argc, char *argv[])
{
  pthread_t threads[NUM_THREADS];
  int rc;
  long t;
  for(t=0;t<NUM_THREADS;t++)
  {
  printf("In main: creating thread %ld\n", t);
  rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
  if (rc){
        printf("ERROR; return code from pthread_create() is %d\n", rc);
        exit(-1);
         }
  }

   /* Last thing that main() should do */
   pthread_exit(NULL);
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:31:31+00:00Added an answer on May 26, 2026 at 12:31 pm

    Because threads are architecture dependent concept, you won’t be able to use pthread without using some kind of a wrapper or use windows-specific threading functions.

    You have three choices

    1. Use pthread-win32 (wrapper for Win32 thread functions :http://sourceware.org/pthreads-win32/ )
    2. Use Windows specific threading functions with #ifdef _WIN32 #else #endif wrapped around
    3. Use boost thread library

    EDIT: for C1010 error follow the above answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems a ridiculously simple question to be asking, but what's the shortest/most idiomatic
I saw this same question for VIM and it has been something that I
I realize this is kind of a long question, but I saw no other
I saw this question asked about C# I would like an answer for PHP.
I saw this question asking about whether globals are bad . As I thought
I saw this question and it motivated me to look again (without success) at
I saw this question Inject into private, package or public field or provide a
I saw this question and it reminded me of AutoGenerateColumns in the old DataGrid.
I saw this quote in this question : MS support is poor, except when
I just saw this question: Understanding .NET’s SecurityAction parameter for permissions And I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.