我正在使用C語言使用IAR Embedded Workbench。聲明不兼容
我在將項目劃分爲通常的main/.h/.c格式時遇到了一些麻煩。
例如,如果我創建一個example.h文件
#ifndef EXAMPLE_H
#define EXAMPLE_H
void function(int [], int);
#endif
而不是example.c
#include "example.h"
void function (int[] array, int number)
{number = 1; //code
}
它說:
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
'int [] array' ???這是C,而不是Java!另外,你說你正在使用「通常的.h/.c格式」,那麼你在C文件中的哪個位置包含相應的H文件? –
當然不是。但這不是告訴它的方式。冷靜下來。對於c文件,看看。 – EagleOne
在'example.h'中你不需要使用'#ifndef EXAMPLE_H',只要你喜歡,你可以多次聲明一個函數原型,只要它們都是一樣的。 –