Undefined reference to "makeWord(unsigned short)" with exit status 1

Hello everyone,

I am a frequent lurker that finally broke down to make an account and join the community. I am currently in a team project for my university that involves making a set of sensors that measure the weight and volume of the trash in a dumpster. My team and I have decided to use four load cells hooked up to SparkFun Load Cell Amplifiers (HX711) and an I2C ultrasonic range finder, the MB7137. The end goal is for our NodeMCU board we are using to sleep for one hour, check if it has been 24 hours, and if so get the sensor data and send it over WiFi to an online data storage site. Currently I am just trying to get the code to compile, but I keep getting the following errors:

Arduino: 1.8.6 (Windows 10), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200”

c:/users/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\Fullcode.ino.cpp.o: in function `takeRangeReading()’:

C:\Users\Desktop\Arduinostuff\Fullcode\Fullcode/Fullcode.ino:88: undefined reference to `makeWord(unsigned short)’

c:/users/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\Fullcode.ino.cpp.o: in function `requestRange()’:

C:\Users\Desktop\Arduinostuff\Fullcode\Fullcode/Fullcode.ino:95: undefined reference to `makeWord(unsigned short)’

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

The code I have is the following:

/* Adopted from Maxbotix datasheet for I2XCL-MaxSonar-EZ Series ultrasonic
 *  range finders
 */

#include <Wire.h>
#include "HX711.h"

#define DOUT  17  
#define CLK  18

HX711 scale1;
float calibration_factor1 = -7500; //load cell assembly specific calobration factor


#define SensorAddress byte(0x70)  // Arduino Wire library uses 7-bit addressing
#define RangeCommand byte(0x51)   // 0x51 for range reading from datasheet
#define ChangeAddressCommand1 byte(0xAA)  // 170
#define ChangeAddressCommand2 byte(0xA5)  // 165

int len = 72, wid = 72, h = 84; // dimesnions of the dumpster in inches

float angletovert = -999.00; // modify this (values between 1 - 90) if you want to use the range finder at an orientation 
                             //other than pointing at the opposite corner
float percentfull = 0.00;


// start up arduino, Wire library, and do all necessary work before going back to Deep Sleep
void setup() {
  Serial.begin(9600); // 9600 Baud
  Serial.setTimeout(2000);

  // Wait for serial to initialize.
  while(!Serial) { }
  
  Wire.begin(); // use Wire library for I2C
  
  scale1.begin(DOUT,CLK);
  scale1.set_scale(calibration_factor1);

  long scale1reading = scale1.read_average(); //Get a baseline reading
  Serial.print("scale1 reading "); 
  //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(scale1reading);

  takeRangeReading();
  delay(150);  // delay in ms; datasheet recommends at least 100ms b/w readings
  unsigned int range = requestRange();  // get range from sensor; word stores a 16-bit unsigned integer
  Serial.print("Range: "); Serial.println(range); // range printout

  percentfull = filllevel(range,maxlengthreading(angletovert));
  Serial.print("percent full: "); Serial.println(percentfull); // pecentfull printout

  
}

void loop() {
}


/*-----------------------------------------------------------------------------------------------*/



// returns the total length of the container's empty measured length as a floating point number
float maxlengthreading(float angletovert){
  float vertang = angletovert;
  float hyp = -1.0;
  if (vertang < 0) {
    float hyp = sqrt(len*len + wid*wid + h*h);
  } else{
    float hyp = h/(cos(vertang));
  }
  return hyp;
}

// returns a decimal form of the amount full based on the input rangefinder measurement and the max length from the maxlengthreading function
float filllevel(float rangereading, float maxlength){
  float flevel = -1.0;
  flevel = 1-((float(rangereading))/maxlength);
  return flevel;
}

//command the volume sensor to take a range reading
void takeRangeReading(){
  Wire.beginTransmission(SensorAddress);  // start addressing
  Wire.write(RangeCommand);  // range command
  Wire.endTransmission();   // stop transmission
}

// command the volume sensor to take a range reading
unsigned int requestRange(){
  Wire.requestFrom(SensorAddress,byte(2));  // return last range sensor read in its last cycle; returns 0 if no communication
   if(Wire.available() >= 2){
     byte  HighByte = Wire.read();
     byte  LowByte = Wire.read();
     unsigned int  range = HighByte*256 + LowByte;
     return range;
      }
    else{
    return word(0);
    }
}

/* Commands sensor at oldAddress to change to newAddress and determines whether
 *  the old address was 7 bit or 8 bit
 */
void changeAddress(byte oldAddress, byte newAddress, boolean SevenBitHuh){
  Wire.beginTransmission(oldAddress);
  Wire.write(ChangeAddressCommand1);
  Wire.write(ChangeAddressCommand2);

  byte temp;
  if(SevenBitHuh){temp = newAddress <<1 ;}
  else  {temp = newAddress;}

  Wire.write(temp);
  Wire.endTransmission();
}

I have been working to get the code to compile for several days and at this point I need some help. Does anyone have any idea what is going on?

My team and I are using url=https://www.amazon.com/HiLetgo-Internet-Development-Wireless-Micropython/dp/B010N1SPRK/ref=sr_1_6?crid=KVOYXRFJZZOF&keywords=esp8266&qid=1555705365&s=gateway&sprefix=esp82%2Caps%2C169&sr=8-6]this board[/url] specifically.

else{
   return word(0);
    }

Why do you think you need this syntax? Try

else{
   return 0;
    }

It's a confusing error because it's talking about this makeWord() but there is no such thing in your code. The reason for this is that word() is a macro defined in the core library:

#define word(...) makeWord(__VA_ARGS__)

macros have a nasty habit of making troubleshooting much more difficult.

I prefer the other style of type casting:

(word)0

The reason is that you can't use the functional style with all types. For example:

unsigned int(0)

I prefer to use the style that can be used consistently through all my code.