[질문] thread 소스 컴파일하는데 애러 나요. 왜 이러죠?

pelsia의 이미지

아래 소스를
cc -o pt -l pthread pt.c
이렇게 컴파일 하는데
cc -o pt -l pthread pt.c
"pt.c", line 24.68: 1506-280 (W) Function argument assignment between types "void*(*)(void*)" and "void(*)()" is not allowed.
이렇게 애러가 나요.
왜 이러죠...?

+1 #include <stdio.h>
+2 #include <errno.h>
+3 #include <pthread.h>
+4
+5 #define SUM_NUM 50000
+6 #define THREAD_NUM 10
+7
+8 void pth_routine();
+9
+10 int s;
+11
+12 main()
+13 {
+14 int i;
+15 pthread_t pth[THREAD_NUM];
+16 pthread_mutex_t ptm;
+17
+18 /* mutex lock 초기화 */
+19 if(pthread_mutex_init(&ptm, (pthread_mutexattr_t *)NULL) != 0)
+20 perror("pthread_mutex_init():");
+21
+22 /* thread 생성 */
+23 for(i = 0; i < THREAD_NUM; i++)
+24 if(pthread_create(&pth[i], (pthread_attr_t *)NULL, pth_routine, (void *)&ptm) != 0)
+25 perror("pthread_create():");
+26
+27 /* thread 모두 종료할 때 까지 대기 */
+28 for(i = 0; i < THREAD_NUM; i ++)
+29 if(pthread_join(pth[i], (void **)NULL) != 0)
+30 perror("pthread_join():");
+31
+32 printf("정상값은 %d << %d >>\n", SUM_NUM * THREAD_NUM, s);
+33 }
+34
+35 void pth_routine(pthread_mutex_t *ptm)
+36 {
+37 int i;
+38
+39 printf("thread_ID : %d\n", pthread_self());
+40
+41 for(i = 0; i < SUM_NUM; i++) {
+42 pthread_mutex_lock(ptm);
+43 s++;
+44 pthread_mutex_unlock(ptm);
+45 }
+46 }

unipro의 이미지

void *pth_routine(void *);

/* ... */

void *pth_routine(void* ptm)
{
    pthread_mutex_t *my_ptm = (pthread_mutex_t *)ptm;

    /* ... */
}

내 블로그: http://unipro.tistory.com

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.