header file의 존재에 따른 컴파일 타임차이,,

pseudolife의 이미지

안녕하세요?

오늘 공부를 하다가,, 막혀서 나아가질 못하고 있습니다 ㅜㅜ

내용인즉,,

a.c
b.c
c.c
이런식으로 소스파일들이 있구요.

각각에 대응되는
a.h
b.h
c.h
헤더파일이 있습니다.

그리고 각 소스파일들이 모두 공통으로 사용하는

s.h
t.h
헤더파일이 있습니다.

이때,

1) 각 소스파일의 상단에 a.h, s.h, t.h를

include 할때 컴파일타임이 낭비될수 있으니

2) 아예 s.h와 t.h를 include하는 std.h라는 파일을 만들어서

각소스파일에 대응하는 *.h파일에 이 std.h를 include하라는 것입니다.

즉 예를 들어 a.c파일은 a.h파일만 include하고

이 a.h파일에 std.h 파일이 include된 형태죠..

1)과 2)가 왜 컴파일타임에서 차이가 나는지 잘모르겠어요..

그리고 이건,, 하나 더 궁금한건데,,

코드에서 #define identifier

이렇게 되어있으면 이게 뭘 말하는건가요?

#define은

#define identifier replacement 가 원래 형식인걸로 아는데,,

고수님들의 조언좀 부탁드립니다.

drinkme의 이미지

1. 무슨 책을 보시는지 모르겠지만, vc++책이 아닌가 하네요.
말씀하시는 대로 차이가 있을리 없습니다. 그리고, 개인적으로 저는 std.h 식으로 만들어서 사용하는 것을
별로 좋아하지 않습니다. 필요한 .c에서 필요한 .h를 명식적으로 include하는게 옳다고 보는 사람입니다.
vc++에는 preheader compiler라는 것이 있어서, project setting에서 std.h를 지정해 주면
해당 header file들을 미리 컴파일 해 놓고, 이것을 사용하는 .c에서 이 내용을 그냥 가져다 사용하는 방식으로
컴파일 시간을 줄일 수 있습니다.

2. #define 중얼중얼
이런 경우 '중얼중얼'은 "값이 없이" 그냥 정의 됩니다.
#ifdef 중얼중얼
식으로 처리가 가능하겠죠.

M.W.Park의 이미지

preheader compiler -> precompiled header
-----
오늘 의 취미는 끝없는, 끝없는 인내다. 1973 法頂

-----
오늘 의 취미는 끝없는, 끝없는 인내다. 1973 法頂

drinkme의 이미지

님은 예리하십니다.

pseudolife의 이미지

답변 감사합니다^^ 많은 도움 되었습니다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.