Re: What is Arduino doing to this code?

Are you asking why the error is about _Z8sendMailv instead of sendMail?

is integral to the ESP8266 standard email client library, so that function call is valid. What were you expecting to be undefined?

What is the purpose of this (void) function prototype in the posted code?

void sendMail();
...
  /* Start sending Email and close the session */
  if (!MailClient.sendMail(&smtp, &message))

I doubt it. If you look at the generated cpp file, you will not find _Z8sendMailv.

Sorry for being vague but as far as I understand it, it's a compiler "thing". Or maybe a linker "thing"; the error message (obviously) comes from the linker.

I occasionally (try to) analyse AVR elf files (avr-objdump -h -S) and I have encountered those additional characters in there as well.

Not your code but you can see extra characters on the last line of this snip.

void sendMail()
{
  if (Serial.available())
 57c:	82 e2       	ldi	r24, 0x22	; 34
 57e:	91 e0       	ldi	r25, 0x01	; 1
 580:	0e 94 28 01 	call	0x250	; 0x250 <_ZN14HardwareSerial9availableEv>

I agree with @sterretje. This is probably due to a well known problem with the preprocessing step in the IDE that generates prototypes and rearranges code. No one seems to have tracked that down, but rearranging the order of includes, and adding your own function prototypes usually makes the problem go away.

If your referring to the builder, sterretje did not say that :wink: I don't know enough about compilers, but I also don't think it's the precompile stage.

If you enable verbose output during compilation and analyse the output, you will be able to find it.

I don't have power at the moment so can't guide you further; a search for sketchname.ino.cpp might do the trick.

I agreed with this statement, but I'm pretty sure the problem is actually in the Arduino preprocessor:

I don't know a way of seeing what the compiler actually sees, although it may help to produce a compiler listing (and off the top of my head, I don't recall how to do that). A bunch of files are created in a temporary directory, perhaps rooting around in that will turn up the modified source code.

As said, enable verbose output during compilation; one of the lines will state "compiling sketch" as shown below; the line after that contains (near the end) the (full path to the) file that is actually compiled.

Compiling sketch...
"C:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\Wim\\AppData\\Local\\Temp\\arduino\\sketches\\B7444A7DDD9C88E1532B662C2305E1B5\\sketch\\1172577.statechange.ino.cpp" -o "C:\\Users\\Wim\\AppData\\Local\\Temp\\arduino\\sketches\\B7444A7DDD9C88E1532B662C2305E1B5\\sketch\\1172577.statechange.ino.cpp.o"

I apologise for being a Windows user :smiley:

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