Error with the definition of macro

Hello Everyone, I am trying to define a macro but I have this error in "#define ERROR_TIMEOUT 1":

exit status 1
return-statement with a value, in function returning 'void' [-fpermissive]

Someone can tell me how to fix this error!

Here is my code:

unsigned long timeout_start;
unsigned long timeout_ms;

String AtCommandCREG = "AT+CREG";
String bufferStringRX;

#define TIMEOUT_2000MS 2000
#define ERROR_TIMEOUT 1
#define TIMEOUT_START { timeout_start = millis(); }
#define TIMEOUT_CHECK { if (millis() - timeout_start > timeout_ms) return ERROR_TIMEOUT; }

void setup() {
  Serial.begin(115200);
  timeout_ms = TIMEOUT_2000MS;
  TIMEOUT_START
  Serial.println(AtCommandCREG);
  while (!Serial.available()) {
    TIMEOUT_CHECK
    delay(1);
  }
  if (! ERROR_TIMEOUT){
    bufferStringRX = Serial.readStringUntil('\n');
  }
}

void loop() {
}

With the macros expanded your setup() function looks like this

void setup()
{
  Serial.begin(115200);
  timeout_ms = TIMEOUT_2000MS;
  TIMEOUT_START
  Serial.println(AtCommandCREG);
  while (!Serial.available())
  {
    {
      if (millis() - timeout_start > timeout_ms) return 1;
    }
    delay(1);
  }
  bufferStringRX = Serial.readStringUntil('\n');
}

setup() is declared void but you are trying to return a value. Even if setup() were not declared void, so what do you imagine the calling function would do with the returned value ?

so what do you imagine the calling function would do with the returned value ?

I have updated my code at the beginning, if ERROR_TIMEOUT 1 this tells me that it has timed out and I should no longer read the serial port

...and it still returns a value from a void function.

If you change code, repost it.
Do not modify earlier code.

That is a bad thing to do as subsequent comments about the original code are now nonsense. Please never do that again

Your amended code still tries to return a value from the void setup() function

void setup()
{
  Serial.begin(115200);
  timeout_ms = 2000;
  {
    timeout_start = millis();
  }
  Serial.println(AtCommandCREG);
  while (!Serial.available())
  {
    {
      if (millis() - timeout_start > timeout_ms) return 1;
    }
    delay(1);
  }
  if (! 1)
  {
    bufferStringRX = Serial.readStringUntil('\n');
  }
}

I ask again where you thing the value is being returned to ?

I already understood my mistake, thanks for your assistance here is my new corrected code:

unsigned long timeout_start;
unsigned long timeout_ms;

String AtCommandCREG = "AT+CREG";
String bufferStringRX;
boolean flagErrorRX = false;

#define TIMEOUT_2000MS 2000
#define TIMEOUT_START { timeout_start = millis(); }
#define TIMEOUT_CHECK { if (millis() - timeout_start > timeout_ms) flagErrorRX = true; }

void setup() {
  Serial.begin(115200);
  Serial.println();
  timeout_ms = TIMEOUT_2000MS;
  TIMEOUT_START
  flagErrorRX = false;
  Serial.println(AtCommandCREG);
  while (!Serial.available() && !flagErrorRX ) {
    TIMEOUT_CHECK
  }
  if ( !flagErrorRX ) {
    bufferStringRX = Serial.readStringUntil('\n');
    Serial.println(bufferStringRX);
  }
  else {
    Serial.println("Elapced Timeout");
  }

  Serial.println("Timeout test finished");
}

void loop() {
}

Why are you using macros in the first place ?

I was looking for how to implement a timeout for the serial port and that it would give me a flag if it was completed and it was the only thing I found, do you have another suggestion?

Yes, put the code that you have put in the macros directly into the sketch

All your macros do is to replace the macro name with the defined text before compiling. Take a look at reply #5 for an example of what your code at that time looks like after the macro substitution and before compiling