스레드 프로그래밍 관련해서 질문입니다

widgie의 이미지

안녕하세요. 책 보면서 스레드 부분 공부하고 있는데

컴파일 하면 에러가 나네요.

Quote:

$ gcc -o thread2 thread2.c -lpthread

thread2.c:10: error: two or more data types in declaration specifiers
thread2.c: In function ‘main’:
thread2.c:29: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type
thread2.c:33: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type

아래는 소스 코드입니다

#include <pthread.h>
#include <stdio.h>
 
struct char_print_parms
{
        char    character;
        int     count;
}
 
void *char_print(void *parameters)
{
        struct char_print_parms *p = (struct char_print_parms*)parameters;
        int i;
        for(i=0;i<p->count;++i)
                fputc(p->character, stderr);
        return NULL;
}
 
int main()
{
        pthread_t thread1_id;
        pthread_t thread2_id;
 
        struct char_print_parms thread1_args;
        struct char_print_parms thread2_args;
 
        thread1_args.character  = 'x';
        thread1_args.count      = 30000;
        pthread_create(&thread1_id, NULL, &char_print, &thread1_args);
 
        thread2_args.character  = 'o';
        thread2_args.count      = 20000;
        pthread_create(&thread2_id, NULL, &char_print, &thread2_args);
 
        pthread_join(thread1_id, NULL);
        pthread_join(thread2_id, NULL);
 
        return 0;
}

뭐가 잘못된건가요?

frag의 이미지

struct char_print_parms
{
        char    character;
        int     count;
};

struct 선언 후 ';' 이 빠졌네요...

widgiee의 이미지

그랬군요 ^^;;

감사합니다