Compiling Error on the Chipkit but not on the arduino


When I try to compil a code on my Chipkit WF 32 I got a failed compiling but not on my arduino mega...

On the IDE I change the board when I compile for the arduino or digilent board. I tryed the arduino IDE and UECIDE and I get the same result, failed on the Chipkit.

I've reduce the code to show you exactly where the error come from, that's come from the convertion of the char array to unsigned integer. I don't know what's happening. If some one have an idea :slight_smile:


void setup()

void loop()

int Motor_2(unsigned char numInputBytes, unsigned char* input, unsigned char* numResponseBytes, unsigned char* response)
//Convertion of the char Array input to unsigned interger (Step to move)
unsigned int Step_To_Move_2 = atoi(input);

Error Message :

Arduino : 1.8.14 Hourly Build 2021/05/11 02:33 (Windows 10), Carte : "chipKIT WF32, Custom / Disabled"

C:\Users\pgrol\Desktop\temporaire\temporaire.ino: In function 'int Motor_2(unsigned char, unsigned char*, unsigned char*, unsigned char*)':
temporaire:12:41: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]
unsigned int Step_To_Move_2 = atoi(input);
In file included from C:\Users\pgrol\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.1.0\cores\pic32/WProgram.h:8:0,
from C:\Users\pgrol\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.1.0\cores\pic32/Arduino.h:4,
from sketch\temporaire.ino.cpp:1:
C:\Users\pgrol\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.1.0\cores\pic32/stdlib_noniso.h:34:5: error: initializing argument 1 of 'int atoi(const char*)' [-fpermissive]
int atoi(const char s);
exit status 255
invalid conversion from 'unsigned char
' to 'const char*' [-fpermissive]

In the IDE, you get a warning, for the Chipkit you get an error. Fix the error and you're good to go :wink:

With warnings set to ALL in file -> preferences, below is the result when compiling in the IDE

/tmp/arduino_modified_sketch_999051/sketch_may17a.ino: In function 'int Motor_2(unsigned char, unsigned char*, unsigned char*, unsigned char*)':
/tmp/arduino_modified_sketch_999051/sketch_may17a.ino:14:41: warning: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]
 unsigned int Step_To_Move_2 = atoi(input);

Thanks for your answer.

I'm not sure to understand, you say I have an error but when I compil this code on the arduino I don't get any error. And everithing works well.

It's different settings used when compiling. It's also a different compiler as far as I can figure out.

Ok, So how I can resolve this problem ?
The problem come from the convertion but I need to convert this char array into an unsigned integer.

I really don't understand why it's working on the arduino mega and not on the chipkit WF32 :neutral_face:

Fix the function parameters; why are you saying that it's an unsigned char?
Change unsigned char* input to char* input.

The compiler settings for AVR boards and the Chipkit are different. You can see [-fpermissive] in the earlier post where I posted the compiler output for the AVR; that indicates that the compiler can decrease, for certain errors, the error level from error to warning and hence it does not stop; but it is actually still an error.

The compiler settings for the Chipkit are different (no idea where to find them as I haven't installed the board); I'm confident that it does not have the fpermissive flag in the compiler options.

1 Like

This is how this function is written, with unsigned char* :

And now you have to be careful. Is input terminated with a '\0'? If so, you can use it in the atoi function as shown below

unsigned int Step_To_Move_2 = atoi((char*)input);
1 Like

Thanks a lot, I try your solution and everithing works well.

But I'm not sure to understand your solution if you can explain me :slight_smile:

It's called a cast. It tells the compiler to treat the variable as a different type.

In this case as a pointer to a char (array) instead of a pointer to a byte (array).

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.