calling functions from external files

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

calling functions from external files

跳至解决方案
1,071 次查看
antony_GB
Contributor I

Hello everybody,

 

                        Please excuse my newb question. The problem I am having is that I can't seem to call functions defined in external files. At the moment, in order to try and do so, I am using the following structure:

 

In "Main.c"

---------------------------------------------------------------

#include "header_file.h"

 

/*call function*/

<r-type> <function_name> ();

---------------------------------------------------------------

 

In "header_file.h"

--------------------------------------------------------------

/*function prototype*/

<r-type> <function_name> (<p-type> <p-name>)

--------------------------------------------------------------

 

In "file_containing_function.c"

-------------------------------------------------------------

/*define function*/

<r-type> <function_name> (<p-type> <p_name>)

{

       some_code;

}

-------------------------------------------------------------

-------------------------------------------------------------

 

The main.c file obviously already exists, however I have added both the "header_file.h" containing the function prototype; and the "file_containing_function.c" which defines my function to my project. Can somebody please explain to me why when in debug mode, I cannot view the 'stack crawl window' step through the function in the external file. It simply seems to bypass the function call altogether.

 

Thanks for your help.  

标签 (1)
0 项奖励
1 解答
388 次查看
CrasyCat
Specialist III

Hello

 

First I assume there is a typo in your initial post. Content of main.c should read as:

 

In "main.c"

---------------------------------------------------------------

#include "header_file.h"

 

<r-type>  retval;

 

/*call function*/

retVal =  <function_name> ();

---------------------------------------------------------------

 

Then next question is which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
   To retrieve that info:
      - Start CodeWarrior
      - Select Help -> About Freescale CodeWarrior
      - Click on "Install Products"
      - CodeWarrior version used is displayed on top in the Installed Products dialog.

 

Finally did you enable generation of debug information on file_containing_function.c?

Please check FAQ-27442 on www.freescale.com for more details on how to figure that out.

 

CrasyCat

在原帖中查看解决方案

0 项奖励
2 回复数
389 次查看
CrasyCat
Specialist III

Hello

 

First I assume there is a typo in your initial post. Content of main.c should read as:

 

In "main.c"

---------------------------------------------------------------

#include "header_file.h"

 

<r-type>  retval;

 

/*call function*/

retVal =  <function_name> ();

---------------------------------------------------------------

 

Then next question is which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
   To retrieve that info:
      - Start CodeWarrior
      - Select Help -> About Freescale CodeWarrior
      - Click on "Install Products"
      - CodeWarrior version used is displayed on top in the Installed Products dialog.

 

Finally did you enable generation of debug information on file_containing_function.c?

Please check FAQ-27442 on www.freescale.com for more details on how to figure that out.

 

CrasyCat

0 项奖励
388 次查看
antony_GB
Contributor I

Thanks CrasyCat for correcting my syntax. Problem solved.

0 项奖励