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
[18274] Re:[질문]DLL에서
박세용 [sypark] 881 읽음    2002-05-08 15:02
전돈교 님이 쓰신 글 :
: Dll 함수 export시 방식이 여러가지가 있잖아요 __pascall __stdcall ...등
: 받는쪽에서 다른 형태로 받아도 되는것인지 궁금합니다. 물론
: 다르게 되면 함수 이름이 틀리게 되어 import가 안되지만 def파일로
: 이름을 맞출수 있잖아요... 그리고 동적 loading으로 사용 할 수도 있기때문에 이름을 맞출수도있으니까... 이름말고 다른 문제가 발생하는가에 대한 질문입니다....
:
:

각각의 export 방식마다 파라메터 전달 및 stack 처리에서 차이가 있습니다.

아래는 빌더의 헬프 화일에서 해당 내용을 가져온 것입니다.

각각 보면, 대소문자 구분이나, _를 함수 앞에 붙이거나 안 붙이고, 스택에

파라메터를 어떤 순서로 쌓아둘건지, 파라메터를 호출된 함수 또는 호출한 함수에서

다시 꺼낼건지...등등에서 차이가 난답니다.


MSVC __fastcall

(Command-line switch: -pm)

This option tells the compiler to substitute the __msfastcall calling convention for any function without an explicitly declared calling convention.

C : 함수명 앞에 _를 붙이고, 대소문자 구분, 파라메터는 우에서 좌 순서로 스택에 넣음

(Command-line switch: -pc, -p-)

This option tells the compiler to generate a C calling sequence for function calls (generate underbars, case sensitive, push parameters right to left). This is the same as declaring all subroutines and functions with the _?cdecl keyword. Functions declared using the C calling convention can take a variable parameter list (the number of parameters does not need to be fixed).

You can use the _?pascal,  _?fastcall, or _?stdcall keywords to specifically declare a function or subroutine using another calling convention.

Pascal : 함수명 모두 대문자로, 호출한 함수에서 스택 청소, 파라메터는 좌에서 우 순서로

(Command-line switch: -p)

This option tells the compiler to generate a Pascal calling sequence for function calls (do not generate underbars, all uppercase, calling function cleans stack, pushes parameters left to right). This is the same as declaring all subroutines and functions with the _?pascal keyword. The resulting function calls are usually smaller and faster than those made with the C (-pc) calling convention. Functions must pass the correct number and type of arguments.

You can use the _?cdecl, _?fastcall, or _?stdcall keywords to specifically declare a function or subroutine using another calling convention.

Register : 레지스터를 파라메터 패스에 사용

(Command-line switch: -pr)

This option forces the compiler to generate all subroutines and all functions using the Register parameter-passing convention, which is equivalent to declaring all subroutine and functions with the _?fastcall keyword. With this option enabled, functions or routines expect parameters to be passed in registers.

You can use the _?pascal, _?cdecl, or _?stdcall keywords to specifically declare a function or subroutine using another calling convention.

Standard Call : 대소문자 구별, 호출된 함수에서 스택 처리, 우에서 좌의 순서로 스택에 저장

(Command-line switch: -ps)

This option tells the compiler to generate a Stdcall calling sequence for function calls (does not generate underscores, preserve case, called function pops the stack, and pushes parameters right to left). This is the same as declaring all subroutines and functions with the _?stdcall keyword. Functions must pass the correct number and type of arguments.

You can use the _?cdecl, _?pascal, _?fastcall keywords to specifically declare a function or subroutine using another calling convention.

Default = C  (-pc)

+ -

관련 글 리스트
18244 [질문]DLL에서 전돈교 796 2002/05/07
18274     Re:[질문]DLL에서 박세용 881 2002/05/08
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.