Absent error message

This caused me a few hours of headscratching:-

int SomeFunction(void)
{
  int MyVar;
  <Body code sets MyVar = one of 0,1,2,3,4>
  return(MyVar);
}

<elsewhere>

int RetVar;
RetVar = SomeFunction; //error here

< more code using RetVar expecting small value>

totally fails because RetVar = 16586 or some similar value
I had missed off the () after SomeFunction
but there is no complaint from the compiler unlike missing ';'

Why is this?

Thanks

your not showing us all your real code.
first of all, all functions need () brackets when calling them weather they have paramiters or not.

if you are still having problems please post a copy paste of the real code you are using and include your function

also you are not telling us what is wrong with your result?

Turn up the compiler warnings in File --> Preferences. You'll probably then see it complaining about assigning a function pointer to an int -- or some such;

Thanks.
I did wonder whether I was getting a pointer rather than the correct return value.
The value was quite consistent between runs.
My code should have returned 0, 1, 2, 3, or 4 as error codes - 0 being no error.
The value seen is way out of the expected range.
I would have thought you needed to be a bit more definite about getting the pointer to a function if indeed that is what it is - maybe it is a pointer to the result or a compiler object reference?

The function name did not occur anywhere else as a variable or other object so I would have expected some sort of 'undefined' warning when allocating it to a variable.

Posting the whole code would not have given any more info as I had solved the problem with the code but was asking why there was no compiler error as I would have expected.

I now know this language needs the '()' when calling a function.

Thanks

So, what did the compiler say when you set compiler warnings to "All"? We can't tell because you didn't post enough code to actually compile. Also, you didn't tell us what board you're compiling for. Also, you didn't tell us which version of the Arduino IDE you're using. Also, you didn't tell us which version of the board package you're using. I'm not really into guessing game.

This code compiles OK - no errors

/*
  Arduino 1.8.9
  Arduino/Genuino
  Mega328 @16MHz
*/
#include <Wire.h>

#define eeprom1 0x50 // default serial EEPROM address
// EEPROM type is 24C256
unsigned int Count;  // byte counter


void setup()
{
   // initialize serial:
  Serial.begin(115200);

  Count = 0;

}

void loop()
{
  int err;
  Count = 2345; // representative value

  err = SendEEHead; // Error here - missing ()
  if (err>0)
  {
    Serial.print("EEPROM Err ");
    switch (err)
    {
      case 1:Serial.print("#1"); break;
      case 2:Serial.print("#2"); break;
      case 3:Serial.print("#3"); break;
      case 4:Serial.print("#4"); break; // expected error codes
      default: Serial.print(err); break; // unexpected error code  
    }
    while (1); // No point continuing
  }
  else
  {
    Serial.print("EEPROM OK ");
    delay(6); // Allow write time
  }
  // do other stuff
  while (1); // Stop here
}



int SendEEHead(void)
{
  unsigned int address;
  int err;

  address = 0;// page 0, modify when necessary
  char MyCount[20];
  Wire.beginTransmission(eeprom1); //eeprom1 is global define
  Wire.write((int)((address) >> 8));   // MSB address
  Wire.write((int)((address) & 0xFF)); // LSB address
  Wire.write("Header ");
  itoa(Count, MyCount, 10);// Count is global unsigned int
  Wire.write(MyCount); // Send Count value as string
  Wire.write(0); // ensure string terminator
  err = Wire.endTransmission(); // send
  // err should be 0 for OK, 1,2,3,4 for an error
  return (err);
}

With Compiler warnings set to 'All' get output:

E:\Development\ArduinoData\sketch_nov20a\sketch_nov20a.ino: In function 'void loop()':

E:\Development\ArduinoData\sketch_nov20a\sketch_nov20a.ino:27:7: warning: invalid conversion from 'int (*)()' to 'int' [-fpermissive]

err = SendEEHead; // Error here - missing ()

^

The default as installed was 'None' and gave no warning (obviously).

So this 'invalid conversion' is not treated as an error and what you get is the pointer to the function as an integer (in this case).

My code no longer uses this construct (when corrected) but I thought it worth asking the question.

Thanks for your interest and suggestions.

I get a compiler error. I have warnings turned up to "All" and I think I even modified the platform.txt file to get rid of where they tell the compiler to make a bunch of errors into warnings.

Arduino: 1.8.10 (Mac OS X), Board: "Arduino/Genuino Uno"


/Users/john/Documents/Arduino/sketch_nov08a/sketch_nov08a.ino: In function 'void setup()':
sketch_nov08a:16:12: error: invalid conversion from 'int (*)()' to 'int' [-fpermissive]
   RetVar = SomeFunction; //error here
            ^~~~~~~~~~~~
exit status 1
invalid conversion from 'int (*)()' to 'int' [-fpermissive]


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.