3

I was working with IAR Embedded Workbench, using C language.

I had some trouble while dividing my project into the usual main/.h/.c form.

For example, if i create an example.h

#ifndef EXAMPLE_H
#define EXAMPLE_H
void function(int [], int);
#endif

And than an example.c

#include "example.h"
void function (int[] array, int number)
{number = 1; //code
}

It says:

Error[Pe147]: declaration is incompatible with "__interwork __softfp 
void function(int *, int)" (declared at line 4 of  (path)

Error[Pe141]: unnamed prototyped parameters not allowed when body is       present  (path)


Error[Pe020]: identifier "number" is undefined  (path)

Error while running C/C++ Compiler 
EagleOne
  • 541
  • 1
  • 10
  • 28
  • 1
    `int[] array`??? This is C, not Java!!! In addition, you say you're using the "usual .h/.c form", then where in the C file do you include the corresponding H file? – barak manos Oct 13 '15 at 20:00
  • 1
    Sure it isn't. But that's not the way to tell it. Chill out. For the c file, just look. – EagleOne Oct 13 '15 at 20:01
  • In `example.h` your use of `#ifndef EXAMPLE_H` is unnecessary, you can declare a function prototype as many times as you like, providing they are all the same. – Weather Vane Oct 13 '15 at 20:02
  • 3
    @WeatherVane: It is still a good practice, as the header file will most likely contain a little bit more than this single function declaration (I believe that its name - example.h - implies this fact in a pretty obvious manner). And in any case, it has nothing to do with the problem at hand. – barak manos Oct 13 '15 at 20:03

3 Answers3

3

The problem is in void function(int [], int). Change to void function(int name[], int) or void function(int *, int). Another error is in int[] array - it has to be int array[] or int * array.

i486
  • 6,491
  • 4
  • 24
  • 41
2

You use wrong syntax. Look at

void function (int array[], int number)
{  number = 1; //code
}
AnatolyS
  • 4,249
  • 18
  • 28
0

In IAR, you will see this error when declaration and definition will not be matching. For Ex- if you declare your variable as __ro_placement in .hpp and during initialization in .c or .cpp, if you will not provide __ro_placement with variable, IAR will throw same error.

Ashish
  • 450
  • 4
  • 5