FILE*

puresupe의 이미지

stdio.h(glibc)
에는 FILE 형 데이터 타입에 대한 typedef나 struct 가 왜 안보일까요?

bushi의 이미지

[bushi@rose net]$ echo "#include <stdio.h>" > t.c
[bushi@rose net]$ gcc -E t.c | grep FILE | grep struct
struct _IO_FILE;
typedef struct _IO_FILE FILE;
typedef struct _IO_FILE __FILE;
struct _IO_jump_t; struct _IO_FILE;
  struct _IO_FILE *_sbuf;
struct _IO_FILE {
  struct _IO_FILE *_chain;
typedef struct _IO_FILE _IO_FILE;
struct _IO_FILE_plus;
extern struct _IO_FILE_plus _IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_;
extern struct _IO_FILE *stdin;
extern struct _IO_FILE *stdout;
extern struct _IO_FILE *stderr;
[bushi@rose net]$ 

[bushi@rose net]$ gcc -v -E t.c 2>&1 | grep include | awk '{print $3}'|uniq
directory
search
 
"/usr/include/stdio.h"
"/usr/include/features.h"
"/usr/include/sys/cdefs.h"
"/usr/include/bits/wordsize.h"
"/usr/include/sys/cdefs.h"
"/usr/include/features.h"
"/usr/include/gnu/stubs.h"
"/usr/include/bits/wordsize.h"
"/usr/include/gnu/stubs.h"
"/usr/include/gnu/stubs-32.h"
"/usr/include/gnu/stubs.h"
"/usr/include/features.h"
"/usr/include/stdio.h"
"/usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h"
"/usr/include/stdio.h"
"/usr/include/bits/types.h"
"/usr/include/bits/wordsize.h"
"/usr/include/bits/types.h"
"/usr/include/bits/typesizes.h"
"/usr/include/bits/types.h"
"/usr/include/stdio.h"
"/usr/include/libio.h"
"/usr/include/_G_config.h"
"/usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h"
"/usr/include/_G_config.h"
"/usr/include/wchar.h"
"/usr/include/_G_config.h"
"/usr/include/libio.h"
"/usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h"
"/usr/include/libio.h"
"/usr/include/stdio.h"
"/usr/include/bits/stdio_lim.h"
"/usr/include/stdio.h"
"/usr/include/bits/sys_errlist.h"
"/usr/include/stdio.h"
[bushi@rose net]$

OTL

puresupe의 이미지

전처리기를 통해서만 확인할수있는건가요?

VC에서의 stdio.h에는 struct ..FILE이 있었는데말이에요.

왜 그럴까요? :D

klara의 이미지

구체적인 구현은 다를수 있습니다만 어딘가 있을텐데요...
전처리기 상관없이 제가 찾아보니 /usr/include/stdio.h 열어보면 typedef struct _IO_FILE FILE; 가 있었습니다.

bushi의 이미지

stdio.h 에서 #include 되는 다른 헤더들을 직접 뒤져보실 의지가 있다면 손수 주적해보세요.
전 귀찮은 일은 컴퓨터에게 맡기자는 주의라 cpp 의 결과를 뽑아서 보여드렸고요.

어디에선가 정의가 되어 있으니 멀쩡히 잘 돌아가겠죠.

OTL