MCUdude / MightyCore

Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535
Other
637 stars 181 forks source link

Error to compile ATMega32 board #255

Closed sony202020 closed 1 year ago

sony202020 commented 1 year ago

Hi, I just try to compile to M32 code but to many error. But if the code I porting and compile using UNO board without error. here the sample of the errors:

C:\Users\Eng-Automation\Documents\Arduino\profibus_M32_2.ino\profibus_M32_2.ino.ino: In function 'void profibus_RX()':
profibus_M32_2.ino:180:35: error: invalid conversion from 'unsigned char' to 'const char*' [-fpermissive]
         if (checksum(uart_buffer[1], 3) != FCS_data) break;
                      ~~~~~~~~~~~~~^
C:\Users\Eng-Automation\Documents\Arduino\profibus_M32_2.ino\profibus_M32_2.ino.ino:734:15: note:   initializing argument 1 of 'unsigned char checksum(const char*, unsigned char)'
 unsigned char checksum(const char *data, unsigned char length)
               ^~~~~~~~
profibus_M32_2.ino:197:22: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]
         if (checksum(&uart_buffer[4], PDU_size) != FCS_data) break;
                      ^~~~~~~~~~~~~~~
C:\Users\Eng-Automation\Documents\Arduino\profibus_M32_2.ino\profibus_M32_2.ino.ino:734:15: note:   initializing argument 1 of 'unsigned char checksum(const char*, unsigned char)'
 unsigned char checksum(const char *data, unsigned char length)
               ^~~~~~~~
profibus_M32_2.ino:214:22: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]
         if (checksum(&uart_buffer[1], 8) != FCS_data) break;
                      ^~~~~~~~~~~~~~~

what should I do?

thank you

MCUdude commented 1 year ago

You're getting the error because the code is compiled without the -fpermissive flag. The flag is left out on purpose because it trick users into thinking that their code is functioning properly.

From StackOverflow:

The -fpermissive flag causes the compiler to report some things that are actually errors (but are permitted by some compilers) as warnings, to permit code to compile even if it doesn't conform to the language rules. You really should fix the underlying problem. Post the smallest, compilable code sample that demonstrates the problem.

So these are your errors, and it should be handled properly: error: invalid conversion from 'unsigned char' to 'const char*' error: invalid conversion from 'unsigned char*' to 'const char*'