function declaration in header file causes C1008 and C1007 errors

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

function declaration in header file causes C1008 and C1007 errors

Jump to solution
1,487 Views
ilya_r
Contributor III

When declaring a function in my header file:

uchar Cooling_Req(float*, float, Table2D*, float*, float, float);

 

I receive C1008 and C1007 errors when making.

 

However, when I move the declaration into the source file, even when put before the #include statement, it work just fine:

 

preprocessed for working order (function declaration out of header file):

/*      404 */  void Timer_1000ms ( void ) ;
/*      405 */  void ResetCAN ( void ) ;
/*      406 */  void StrokeData ( void ) ;
/*      411 */

/**** FILE 'C:\Users\rozeni1\Documents\SCC\Fan\Sources\strategy.c' */

uchar Cooling_Req ( float * , float , Table2D * , float * , float , float ) ;
/*       17 */

/**** FILE 'strategy.h' */


/*       40 */  float Strategy ( void ) ;
/*       46 */

/**** FILE 'C:\Users\rozeni1\Documents\SCC\Fan\Sources\strategy.c' */


/*       19 */  extern const uchar STRATEGY ;
/*       20 */  extern const uchar COOLANT_I ;
/*       21 */  extern const uchar AC_I ;

 

 

 

preprocessed for non-working (function declaration in header file):

/*      402 */  void Timer_250ms ( void ) ;
/*      403 */  void Timer_500ms ( void ) ;
/*      404 */  void Timer_1000ms ( void ) ;
/*      405 */  void ResetCAN ( void ) ;
/*      406 */  void StrokeData ( void ) ;
/*      411 */

/**** FILE 'C:\Users\rozeni1\Documents\SCC\Fan\Sources\strategy.c' */


/*       16 */

/**** FILE 'strategy.h' */


/*       40 */  float Strategy ( void ) ;
/*       41 */  uchar Cooling_Req ( float * , float , Table2D * , float * , float , float ) ;
/*       46 */

/**** FILE 'C:\Users\rozeni1\Documents\SCC\Fan\Sources\strategy.c' */


/*       17 */  extern const uchar STRATEGY ;
/*       18 */  extern const uchar COOLANT_I ;
/*       19 */  extern const uchar AC_I ;

Labels (1)
0 Kudos
1 Solution
1,163 Views
ilya_r
Contributor III

Hello all,

I moved the #include header statements that cast "uchar" and "Table2D" from the source file to header file that has the problematic function declaration and it solved the problem.

However, this has never been a problem before, as long as I listed my #include statements in the right order at the top of the source file any casting would automatically filter down to subsequent headers below.

Again, looking at the preprocessor output, in both cases the function protocol is listed in approximately the same place, but one works, and the other throws up errors.

View solution in original post

0 Kudos
7 Replies
1,164 Views
ilya_r
Contributor III

Hello all,

I moved the #include header statements that cast "uchar" and "Table2D" from the source file to header file that has the problematic function declaration and it solved the problem.

However, this has never been a problem before, as long as I listed my #include statements in the right order at the top of the source file any casting would automatically filter down to subsequent headers below.

Again, looking at the preprocessor output, in both cases the function protocol is listed in approximately the same place, but one works, and the other throws up errors.

0 Kudos
1,163 Views
DustyStew
Contributor V

ilya

I have experienced a similar if not the same problem, compiling for S12G in the classic IDE.

I've been using C compilers for 30 years and never had so many problems with a compiler.

C compiler error messages are known to not make sense, but this compiler takes not making sense to a new level.

Random changes fix things. For instance, it seems in some cases recreate your project from scratch with the same files, and it might work. Lord knows what's wrong with this compiler, but somehow I doubt anyone is going to fix it.

0 Kudos
1,163 Views
BlackNight
NXP Employee
NXP Employee

I guess your problem is that with

     uchar Cooling_Req(float*, float, Table2D*, float*, float, float);

in your header file at this location the compiler does not know anything about 'uchar' and 'Table2D'.

You can verify this if you change (temporarily) it to

     char Cooling_Req(float*, float, void*, float*, float, float);

So where are the types of uchar and Table2D declared?

Before using it, you need to include the header for it.

So if in your header you are using such non-standard types, you need to include that header too in your header file.

This is standard C/C++ coding guideline in my view.

For example you have

/* File ABC.h */

#ifndef ABC_H_

#define ABC_H_

typedef unsigned int ABC_Type;

#endif

/* end of ABC.h*/

and you use ABD_Type in a header (or anywhere else), you need to include that header file too:

/* File XYZ.h */

#ifndef XYZ_H_

#define XYZ_H_

#include "ABC.h"  /* include this header, as we are using content of ABC.h below! */

void XYZ_foo(ABC_Type *param);

#endif

/* end of ABC.h*/

I hope that makes sense.

Erich

0 Kudos
1,163 Views
ilya_r
Contributor III

I am defining "uchar" and "Table2D" in a header file being listed before the one w/ the function protocol.

0 Kudos
1,163 Views
TICS_Fiona
NXP Employee
NXP Employee

What else is contained in the head file? Like variable definition and function entity? Please move them in C file. 

If this does not help, could you please attach a simple project to help us reproduce the error? Thank you very much.

We also need to know the CodeWarrior version you are using,

For Classic CodeWarrior, please:

1)Start the IDE and click on Help | About Freescale(Metrowerks) CodeWarrior.

2)Click on Installed Products

3)Provide us all info displayed. Or you can save them in a txt file.

For Eclipse CodeWarrior, please:

1)Start the IDE and click on Help | About CodeWarrior Development Studio.

2)Provide us the info displayed.

Best Regards

Fiona

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

Note: If this post answers your question, please click the Correct Answer button. Thank you!

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

0 Kudos
1,163 Views
ilya_r
Contributor III


Here you go

0 Kudos
1,163 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

can you please upload your project here?

0 Kudos