[SOLVED] I can't use "Serialprint" command for variables that change

Hey, I am trying to learn some things in Arduino and I am having a problem, searched all the internet as much as I can but found nothing. Whenever I try to compile my code with "Serialprint" command it gives me that error:

Arduino:1.8.19 (Linux), Kart:"Arduino Uno"

during RTL pass: combine
/usr/share/arduino/hardware/archlinux-arduino/avr/cores/arduino/main.cpp: In function 'main':
/usr/share/arduino/hardware/archlinux-arduino/avr/cores/arduino/main.cpp:51:1: internal compiler error: in add_clobbers, at config/avr/avr-dimode.md:2705
   51 | }
      | ^
0x132fb8b diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1], diagnostic_t)
	???:0
0x1330acd internal_error(char const*, ...)
	???:0
0x5a8992 fancy_abort(char const*, int, char const*)
	???:0
0x59f067 add_clobbers(rtx_def*, int) [clone .cold]
	???:0
0x1143d97 recog_for_combine_1(rtx_def**, rtx_insn*, rtx_def**)
	???:0
0x114608e recog_for_combine(rtx_def**, rtx_insn*, rtx_def**)
	???:0
0x1158fa5 try_combine(rtx_insn*, rtx_insn*, rtx_insn*, rtx_insn*, int*, rtx_insn*)
	???:0
0x115c2a4 (anonymous namespace)::pass_combine::execute(function*)
	???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
lto-wrapper: fatal error: /usr/bin/avr-gcc returned 1 exit status
compilation terminated.
/usr/bin/avr-ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
exit status 1
Arduino Uno kartı için derleme hatası.

Here is my code if it helps:

#define trigPin 4
#define echoPin 2
long sure, mesafe;

void setup () {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

Serial.println("Arduino İle Mesafe Sensörü Uygulaması Başlatılıyor...");
delay(3000);
}
void loop () {
digitalWrite(trigPin, LOW);
delayMicroseconds(3);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

sure = pulseIn(echoPin, HIGH);

mesafe = (sure/2) * 0.343;
Serial.print(mesafe);
Serial.println(" cm uzaklıkta");
delay(500);
}
1 Like

Your problem doesn't appear to have anything to do with Arduino or your code, per se, but appears to be an internal compiler problem.

Can you try to compile this?

const byte trigPin = 4;
const byte echoPin = 2;

void setup ()
{
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  digitalWrite (trigPin, LOW);
  pinMode(echoPin, INPUT);

  Serial.println("Arduino");
  delay(3000);
}

void loop () 
{
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  unsigned long sure = pulseIn(echoPin, HIGH);
  long mesafe = (sure/2) * 0.343;
  Serial.print(mesafe);
  Serial.println(" cm");
  delay(500);
}

Your sketch compiles without error or warning for me on a Macintosh. It looks like there is something going wrong in your Arduino installation.

mesafe = sure / 59;

You might be right. This code showed me the same error too.

Yep, this is an example code from the internet and there are people who tells that code is fine so it definitely is about me. What can I do to fix my Arduino installation. I am in Manjaro btw, if that helps.

Re-install? Get the latest supported build from https://www.arduino.cc/en/software
After installing, go to Tools -> Board: -> Boards Manager... and update any board packages that appear when you set "Type" to "Updatable".

Those two lines are not equivalent.

I didn't have any issues on Linux mint 17.3
This was using IDE 1.8.19 from the 64 bit Linux tar ball

Where did you get your IDE from?
Can you turn on verbose output and post it so we can see what toolset is being used and all the command line options?

These days it is a total PITA the way the IDE works since you can longer be assured what toolset you end up using since add on packages for additional boards (like add adding board support for additional AVR boards) can alter the tool set used by boards outside that package.
i.e. add package X to the IDE to add support for board A and it can override the toolset and potentially break builds for previously installed package Y when building for board B.

IMO, this is a terrible "feature" that was added to the IDE and is just plain wrong headed.
IMO, board packages should be independent and should not have the capability to break builds for boards in other separate/independent board packages.

--- bill

Hey, I just downloaded another one from "Boards Manager". I used "Arduino AVR Boards" instead of "Arch Linux Arduino AVR Boards" and no idea why but it works perfectly fine now.

Thanks everyone who tried to help <3

1 Like

of course. his line is incorrect.

So is yours, it is just incorrect in a completely different way, and the error has nothing to do with the problem OP is experiencing.

(Note: 0.343 / 2 is not equal to 1/59.)

Hey, it's fine guys. Thanks for correcting my code kolaha. No need to argue about it ^^

1 Like

Note: 0.343 / 2 is not correct formula to calculate centimeter from ping microseconds

None of it is - there is no temperature correction.

Thank you for this. Had the exact same issue and also using Manjaro.

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