컴파일시 전처리기로 메세지 보기..

vidocq의 이미지

컴파일시에 전처리기로 메세지를 나타내게 할수 있는 방법이 있는 것으로 아는데요,
잘 생각이 안나서 질문 올립니다.

가령
#ifdef LOGO
start_logo();
#else
start_nologo();
#endif

이런 소스에서 LOGO 가 define 되어 있는지 보이면 쉽게 알수 있지만
어디에 숨어있는지 모르면 실행하면서 printf로 찍어보잖아요.
이러지 않고 컴파일 시에 에러메세지를 이용해서 컴파일 결과로 알수 있는 방법이 있는데요...
# 을 써서 define 문 처럼 쓰던데...
아시는 분들 답변 부탁드립니다.

좋은하루 되세요.

elecguy의 이미지

#warning : 경고 문구..
#error : 정말 에러내고 컴파일 정지.

인데..
#message 이런 비슷한 것은 본적이 없네요..

폐인, 노가다 그 끝은..?

vidocq의 이미지

답변감사합니다.

실제로 해보니까
#error 은 잘 적용이 됩니다.
그러나 에러가 발생해서 여러가지 경우의 메세지를 한번에 볼수가 없습니다.
#warning 와 #message 는 적용되지 않더군요.

시스템과 컴파일러 마다 약간 차이가 있을거 같은데요.
혹시 다른 방법을 알고 계신 분은 답변 부탁드립니다.

제가 하고 싶은 것은

#ifdef LOGO 
#error "Setted LOGO\r\n"
#endif

#ifdef SCREEN
#error "Setted SCREEN\r\n"
#endif

#ifdef X_PROTOCOL
#error "Setted X_PROTOCOL\r\n"
#endif

이렇게 define 된 조건들 확인과 기타 값들 확인에 있습니다.
#error 을 사용할 경우 한가지만 걸리더라도 에러가 나서 진행이 안되기 때문에 다른 방법을 알고 계신분은 답변 부탁드립니다.

미리 감사드리고요...

참고로 제가 사용하는 환경은
Windows 에 djgpp 입니다.

kuma의 이미지

Visual C/C++ Ver 6.0 Pro. 에서는

#pragma message ("abcdef" )

이렇게 메세지 출력용으로 사용합니다.

댓글 달기

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