尝试在 MPLAB 中使用chipKit 内核时出现“错误:预期标识符...”,但在 Arduino IDE 中不存在错误

问题描述

正如标题所述,我正在尝试在 MPLAB X IDE 中使用芯片套件内核。我这样做是因为我希望能够正确调试我用于该项目的 PIC32 板,但我没有时间重新编写该项目的所有 Arduino/Arduino-alike 库已经在用了。

但是,在尝试编译时,我遇到了chipkit 代码中的问题(甚至不是我的代码!)。 目前困扰我的错误是:

In file included from ../../chipKit_pic32/2.1.0/cores/pic32/noniso.c:25:0:
../../chipKit_pic32/2.1.0/cores/pic32/stdlib_noniso.h:34:5: error: expected identifier or '(' before 'int'
 int atoi(const char *s);
     ^
../../chipKit_pic32/2.1.0/cores/pic32/stdlib_noniso.h:36:6: error: expected identifier or '(' before 'long'
 long atol(const char* s);
      ^
../../chipKit_pic32/2.1.0/cores/pic32/stdlib_noniso.h:38:8: error: expected declaration specifiers or '...' before numeric constant
 double atof(const char* s);
        ^
../../chipKit_pic32/2.1.0/cores/pic32/stdlib_noniso.h:38:8: error: expected declaration specifiers or '...' before numeric constant
 double atof(const char* s);
        ^

我只能假设我错过了一些愚蠢的东西,但我一生都找不到它。

文件“stdlib_noniso.h”如下:

#ifndef STDLIB_NONISO_H
#define STDLIB_NONISO_H

//#define _NEED_REVERSE
//#define _NEED_LTOA
//#define _NEED_ULTOA
#define _NEED_DTOSTRF

#ifdef __cplusplus
extern "C"{
#endif

int atoi(const char *s);

long atol(const char* s);

double atof(const char* s);

char* itoa (int val,char *s,int radix);

#ifdef _NEED_LTOA
char* ltoa (long val,int radix);
#endif

char* utoa (unsigned int val,int radix);

#ifdef _NEED_ULTOA
char* ultoa (unsigned long val,int radix);
#endif
 
#ifdef _NEED_DTOSTRF
char* dtostrf (double val,signed char width,unsigned char prec,char *s);
#endif

#ifdef _NEED_REVERSE
void reverse(char* begin,char* end);
#endif

#ifdef __cplusplus
} // extern "C"
#endif


#endif

我不想成为一个糟糕的提问者,但我不知道我应该添加哪些其他信息。 我一直在寻找可能导致问题的宏,并查看了#include stdlib_noniso.h 的文件,但我也找不到任何内容。 作为记录,包含它的文件是 WProgram.h、WString.h 和 noniso.c,所有这些文件也是chipkit 核心的一部分。

解决方法

您是否使用了chipKIT 项目导入器?我从不厌倦使用 MPLAB 调试草图,但我知道其他人已经这样做了。这不是很有帮助,但我认为有一个教程我会继续寻找:https://chipkit.net/debug-chipkit-sketches-in-mplab-x-ide/

编辑:找到进口商说明: https://chipkit.net/wiki/index.php?title=MPLABX_Importer