함수 선언 누락에 대한 링커 경고

기술노트 95495

아키텍처:

ARM, RH850, RX, SH, STM8, RL78

컴포넌트:

general

업데이트:

2018-02-28 오전 2:26

Introduction

From a user : I had missed to declare some functions. So, by mistake, I had different parameters in the definition of the function and the call(s) to the same function. My application ended up with a difficult-to-find-run-time error.

My question is:

Why didn't the IAR ILINK Linker linker warn me?

Background

  • The problem/risk occur when implicit declarations (no declaration in the compiling unit) are used.
  • Compared to the UBROF output format (used in some IAR Embedded Workbench products), this is a limitation with the ELF format that the compiler and linker are using.
  • IAR is aware of this limitation in ELF.
  • There are no plans for the moment to create this kind of type check in IAR ILINK Linker.

Solution

Let the compiler find these problems, by enabling:

 Project > Options > C/C++ Compiler > Language > C dialect > Require prototypes.

On the compiler command line, the option to use is:

--require_prototypes

Then, create a header file with the declarations and use that wherever functions are defined or called.

 

All product names are trademarks or registered trademarks of their respective owners.

죄송하지만, 당사 사이트에서는 Internet Explorer를 지원하지 않습니다.보다 편안한 사이트를 위해 Chrome, Edge, Firefox 등과 같은 최신 브라우저를 사용해 주시길 부탁드립니다.