C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[44970] Re:Re:Re:ASSERT 사용 질문
권혁균 [orion47] 919 읽음    2006-05-22 15:57
질문드림 님이 쓰신 글 :
: char *buf=0;
:   //buf = (char *) calloc( 20, sizeof(char) );
:   _ASSERT( buf != NULL );
:   strcpy( buf, "Hello, World" );
:   free( buf );
:
:   이라고 해서 프로그램을 실행 시켜보면 Access Violation이 발생합니다.
:
_ASSERT, _ASSERTE Macros
Evaluate an expression and generate a debug report when the result is FALSE (debug version only).

위의 설명과 같이 ()의 연산이 false면 Access Violation이 발생됩니다.
_ASSERT( buf != NULL ); --> if (buf == NULL), generate a debug report
주석을 푸시면 정상일겁니다.

<아래글도 추가로 읽어보시고 참고하시길..>
The _ASSERT and _ASSERTE macros provide an application with a clean and simple mechanism for checking assumptions during the debugging process. They are very flexible because they do not need to be enclosed in #ifdef statements to prevent them from being called in a retail build of an application. This flexibility is achieved by using the _DEBUG macro. _ASSERT and _ASSERTE are only available when _DEBUG is defined. When _DEBUG is not defined, calls to these macros are removed during preprocessing.

_ASSERT and _ASSERTE evaluate their booleanExpression argument and when the result is FALSE (0), they print a diagnostic message and call _CrtDbgReport to generate a debug report. The _ASSERT macro prints a simple diagnostic message, while _ASSERTE includes a string representation of the failed expression in the message. These macros do nothing when booleanExpression evaluates to nonzero.

Because the _ASSERTE macro specifies the failed expression in the generated report, it enables users to identify the problem without referring to the application source code. However, a disadvantage exists in that every expression evaluated by _ASSERTE must be included in the debug version of your application as a string constant. Therefore, if a large number of calls are made to _ASSERTE, these expressions can take up a significant amount of space.

+ -

관련 글 리스트
44961 ASSERT 사용 질문 질문드림 947 2006/05/22
44964     Re:ASSERT 사용 질문 김태선 1122 2006/05/22
44965         Re:Re:ASSERT 사용 질문 질문드림 1070 2006/05/22
44970             Re:Re:Re:ASSERT 사용 질문 권혁균 919 2006/05/22
44977                 Re:Re:Re:Re:ASSERT 사용 재질문 질문드림 1013 2006/05/23
44978                     Re:Re:Re:Re:Re:ASSERT 사용 재질문 김태선 1231 2006/05/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.