쓰레드를 생성하는 예제를 컴파일 시 에러가 납니다.
글쓴이: embeddeds0 / 작성시간: 금, 2013/05/03 - 11:06오후
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/unistd.h>
#include <sched.h>
int g=2;
int sub_func(void *arg)
{
g++;
printf("PID(%d) : Child g=%d \n", getpid(), g);
return 0;
}
int main(void)
{
int pid;
int child_stack(4096);
int l = 3;
printf("PID(%d) : Parent g=%d, l=%d \n", getpid(), g, l);
clone(sub_func, (void *)(child_stack+4095), CLONE_VM | CLONE_THREAD | CLONE_SIGHAND, NULL);
sleep(1);
printf("PID(%d) : Parent g=%d, l=%d \n", getpid(), g, l);
return 0;
}#gcc -O2 -o clone clone.c
error : 'CLONE_VM' undeclared (first use in this function)
note : each undeclared identifier is reported onlt once for each function it appears in
error : 'CLONE_THREAD' undeclared (first use in this function)
error : 'CLONE_SIGHAND' undeclared (first use in this function)
위와 같은 에러가 계속 발생되네요.. 뭐가 문제인가요..?
Forums:


이렇게 해보세요.
note : each undeclared identifier is reported onlt once for each function it appears in
http://kldp.org/node/132291
Linux/include/uapi/linux/sched.h
#define CLONE_VM 0x00000100 /* set if VM shared between processes */
#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
#define CLONE_THREAD 0x00010000 /* Same thread group? */
http://lxr.free-electrons.com/source/include/uapi/linux/sched.h#L8
http://lxr.free-electrons.com/ident?i=CLONE_THREAD
커널 컴파일시 PATH_MAX 오류 해결 방법
http://forum.falinux.com/zbxe/index.php?document_srl=480339&mid=question
http://kldp.org/node/28653
----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.
매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.
각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com
음 ..
clone 의 man page 를 보면.. 다음과 같이 되어 있죠.
SYNOPSIS #define _GNU_SOURCE /* See feature_test_macros(7) */ #include <sched.h> int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ... /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ );sched.h 를 include 하기 전에 _GNU_SOURCE 를 define 하란 뜻입니다.
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
간단한 문제입니다.
#include 가아니라 #include 로 해보세요
#include 로 해더 파일 바꿔보세요.
#include 로 해더 파일 바꿔보세요.
#include sched.h 에서
#include sched.h 에서
sched.h 를 linux/sched.h 로 바꿔보세요.
angle bracket과 그 내부 표현은 나타지 않네여.;;
댓글 달기